Re: Feature like "acts_as" in Django ORM or contrib ?

2008-10-21 Thread shabda
Ordering: qs = Model.objects.filter(...).order_by('ordering_field') ord_list = [el for el in qs] Versioning: code.google.com/p/django-rcsfield (There are a few others, cant remember the names offhand.) On Oct 21, 12:13 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 21 oct, 08:37, Dan

Order of fields reset on Dynamically generated Forms.

2008-10-27 Thread shabda
I need to use DynamicForm(form generated using database values), so I am using this method, http://uswaretech.com/blog/2008/10/dynamic-forms-with-django/ Now the order in which I define the fields is not the same as that for the rendered Html. If I change the line like setattr(EmployeeForm, fiel

Re: trying to understand get_absolute_url, NoReverseMatch and url configs

2008-10-27 Thread shabda
You want something like this @models.permalink def get_absolute_url(self): return ('orgs.views.org', [self.type.slug, self.slug]) Essentially, you code would be doing something like reverse('/org/ hoa/', kwargs={..}) which fails. Templates supress Exceptions so you do not see them. On Oct

How to get the Html representation of forms.Fields

2008-10-28 Thread shabda
I have some forms.Fields, which are not attached to any forms.Form. How can I get the Html representation of it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Why is my string not auto escaped?

2008-10-29 Thread shabda
I need to create a custom filter which displays some data from db depending on its data type. My code is something like, from django.template.defaultfilters import linebreaks, urlize def filterxx(data) return linebreaks(urlize(data.value)) My data.value is Asdfghjkl alert('hole') This

Re: Why is my string not auto escaped?

2008-10-29 Thread shabda
So if these built in filters are marking my strings safe, inspite of unsafe data being passed in, should they not handle escaping as well? Rajesh Dhawan wrote: > On Oct 29, 8:35 am, shabda <[EMAIL PROTECTED]> wrote: > > I need to create a custom filter which displays so

Filtering the modelform in Admin on request.user

2008-11-06 Thread shabda
I have an Admin site which I want to filter based on request.user. My ModelAdmin class is something like this, class FilterOnUser(admin.ModelAdmin): def queryset(self, request): return self.model._default_manager.filter(user = request.user) def get_form(self, request, obj=None,

How do test Middleware

2008-11-14 Thread shabda
I want to write some test for my middleware seperate from the views that would be using them. So I am using this snippet http://www.djangosnippets.org/snippets/963/ to get a request, and calling my middleware with it to test it, but it looks a little hackish to me. Is there a better way? --~--~---

Is there a place from where I can get the completed code for the Django 4-part tutorial?

2008-11-17 Thread shabda
Is there a place where I can get the app completed as part of http://docs.djangoproject.com/en/dev/intro/tutorial04/#intro-tutorial04 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to th

Anyone maintaining a Svn repo for django-registration?

2008-12-16 Thread shabda
Django registration has moved from googlecode to Bitbucket, which means my projects which are svn:externaled to django-registration might not get the latest code. Is anyone maintaining an svn repository which is I can svn:external to? --~--~-~--~~~---~--~~ You recei

Possible pug with Model inheritence - Inserts instead of Update

2008-10-12 Thread shabda
]: shabda = Foo(name = 'Shabda') In [3]: shabda.save() In [4]: Foo.objects.all() Out[4]: [] In [5]: shabda.name = 'Shabda Raaj' In [6]: shabda.save() In [7]: Foo.objects.all() Out[7]: [, ] Which is what I expect. Now doing the same thing to Bar In [1]: from djcalendar.m

How can I check which view is being called in response to a specific Url?

2008-10-12 Thread shabda
One of my views is returning a Http404, and I think it is calling a view function diffrent from what I am expecting to be called. So How can I check which view is being called in response to a specific Url? --~--~-~--~~~---~--~~ You received this message because yo

Re: Possible pug with Model inheritence - Inserts instead of Update

2008-10-12 Thread shabda
> so I would expect more problems > > On Oct 12, 9:16 am, shabda <[EMAIL PROTECTED]> wrote: > > > My models.py > > > class Foo(models.Model): > >     name = models.CharField(max_length = 100) > > >     def save(self): > >         self.i

Writing a subclassable Django singleton model

2009-03-10 Thread shabda
ts.count() Out[5]: 1 In [6]: y=SubSingleton(name='a', tag='b') In [7]: y.save() --- AttributeErrorTraceback (most recent call last) /home/shabda/django_design_pats/ in () /home/sh

Value proposition of Rails

2009-03-18 Thread shabda
[Trying not be trollish, but the subject might be so. My apologies in advance.] I run a small Django development firm ( www.uswaretech.com ), and a lot of clients we go after need to be convinced on why they should choose Django. What is your experience in this? Specifically am I looking for is,

Cross post from Djangoindia list: [Pycon] IRC Meeting to discuss how to represent Django

2009-08-10 Thread shabda
oF [1] sessions. Shabda will let us know the venue of the IRC meeting. In the meantime, let us decide on a suitable timing for the meeting. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group.

Providing defaults to models

2007-06-18 Thread shabda
Hi, I have a model class like this class Link(models.Model): link = models.URLField() user = models.ForeignKey(User, unique=False) text = models.TextField(maxlength = 20) votes = models.IntegerField() I want some of the fields to have defaults, like I want votes to have a defaul

Re: Providing defaults to models

2007-06-18 Thread shabda
ue of ``None`` So providing default values for models should be possible. On Jun 18, 9:30 pm, shabda <[EMAIL PROTECTED]> wrote: > Hi, > > I have a model class like this > > class Link(models.Model): > link = models.URLField() > user = models.ForeignKey(User, unique=F

Developing without tempplates

2007-06-18 Thread shabda
Hi, I am prototyping an app. Since I am just prtotyping I do not want to write templates yet. SO is there some way wherein all my variables in the view method get out put to the screen, so that I can debug them? --~--~-~--~~~---~--~~ You received this message bec

Re: Developing without tempplates

2007-06-18 Thread shabda
Also using locals() and printing is not very useful as it dumps too much data to screen to be any use. On Jun 18, 10:04 pm, shabda <[EMAIL PROTECTED]> wrote: > Hi, > > I am prototyping an app. Since I am just prtotyping I do not want to > write templates yet. SO is there some

recommendations for hosts

2007-06-18 Thread shabda
Hi, What host do you people recommend for hosting a small-medium traffic django site. Its just a hobby hobby site so I dont want too costly a host, but since this is the first django app I would be hosting, I would prefer a host with reasonable support and one which specialises in django. --~--

how to define stored procedures within django

2007-06-21 Thread shabda
Hi, I want to use some stored procedures. I am mySql. Is there some way I can define stored procedures from withing django? (We can call already defined procedures, http://www.djangosnippets.org/snippets/118/ discusses how, but can we also define stored procedures from within django?) --~--~--

Re: how to define stored procedures within django

2007-06-21 Thread shabda
thanks, That solves my problem. On Jun 21, 11:05 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > I want to use some stored procedures. I am mySql. Is there > > some way I can define stored procedures from withing django? > > (We can call already defined procedures, > >http://www.djangosnippets.org/s

How to install django on Apache/Linux

2007-08-18 Thread shabda
I have apache installed on linux with mod_php, mysql. I am trying to get django working here, and am following the intsallation steps at http://www.djangobook.com/en/beta/chapter21/ . Step 1. Install mod_python did yum install mod_python. Checked that mod_python is installed. Step 2. Add this to y

How to install mysql-python

2007-08-19 Thread shabda
I am trying to setup django with mysql, After installing django and mysql I am trying to set up mysql-python. So I give the command $ easy_install MySQL-python And am getting a ton of errors. On the page http://www.djangobook.com/en/beta/chapter02/, under comments for mysql it says, "Don't forget

Re: How to install mysql-python

2007-08-19 Thread shabda
_mysql.c:2878: warning: assignment makes pointer from integer without a cast _mysql.c:2883: error: `PyExc_ImportError' undeclared (first use in this function) error: command 'gcc' failed with exit status 1 3. cd /sw/lib/mysql (that file is not on my system) So unabl;e to build the My

Re: How to install mysql-python

2007-08-19 Thread shabda
Yes the problem was with python-devel. After installing all the depndebcies, it went through fine. On Aug 19, 1:20 pm, Thejaswi Puthraya <[EMAIL PROTECTED]> wrote: > On Aug 19, 1:16 pm, shabda <[EMAIL PROTECTED]> wrote: > > > But even that is not helping. I am on a

Problems with syncdb

2007-08-22 Thread shabda
When I run the command $ python manage.py syncdb I am getting an error like Failed to install index for auth.Message model: (2006, 'MySQL server has gone away')Installing index for auth.Permission model I am on python 2.3.4, mysql 5.0.46, cent OS. My tables get created though. What can be the pro

How to convert a Django model item to the underlying python object

2007-09-03 Thread shabda
I need to convert a models.datefield to a python type. How can I do this. In general what is the way to convert the django model data type to a pure python data type? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

How to add a non database item to a python model

2007-09-03 Thread shabda
I have a python model class MyModel(models.Model): fld1 = models.TextField() fld1 = models.TextField() I want to have a non database item in this model class, which I can populate in the views. What is the recommended way to do this. --~--~-~--~~~---

Re: hai am new one to django

2007-09-05 Thread shabda
http://diveintomark.org/archives/2004/07/06/nfc I was walking across a bridge one day, and I saw a man standing on the edge, about to jump off. So I ran over and said, "Stop! Don't do it!" "I can't help it," he cried. "I've lost my will to live." "What do you do for a living?" I asked. He said

Re: How to add a non database item to a python model

2007-09-05 Thread shabda
That seems too easy to be true. :). I have one more query, where should I add this code? Considering this attribute would be used in many views, I am trying to override __init__. def __init__(self, *vargs): models.Model.__init__(self, *vargs) self.my_item_that_doesnt_exist_in_

Re: How to add a non database item to a python model

2007-09-05 Thread shabda
Oh shucks, since I want to recalculate this attribute each time, I would need this to be in the view function. Still how would I override __init__ in django Models? On Sep 5, 11:10 pm, shabda <[EMAIL PROTECTED]> wrote: > That seems too easy to be true. :). > I have one more query, wh

Re: How to add a non database item to a python model

2007-09-05 Thread shabda
Traceback (most recent call last): File "C:\Python24\lib\site-packages\django\core\handlers\base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "C:\Python24\lib\site-packages\django\contrib\auth\decorators.py" in _checklogin 14. return view_func(re

How to start shell without ipython

2007-09-08 Thread shabda
I need to write some doctests for my app. So I am running the interactive shell by manage.py shell But since ipython is already installed on my system, the i python prompt starts and I can't just copy paste the shell output for creating the doctests. Is there some way I can ask the manage.py uti

Problems with deploying django

2007-09-10 Thread shabda
I am trying to deploy django on a fedora 7 system. After following these steps I am stuck! (Long tale of woes ahead, If you can just tell me where can I get apxs for apache, my problem is solved.) 1. Downloaded django, tried running setup.py, got an error saying something like unable to open /usr

More deployment woes

2007-09-10 Thread shabda
I am trying to deploy django, and to test the install I am doing this, I run django-admin.py startproject hello in directory /root/django I have added to my httpd.conf SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE hello.settings

django-websearch

2008-01-05 Thread shabda
Many of us would like to do a search for our website from within django. With django-websearch[1] you can do a search for your site, any general search on the web. I had talked about this a long time ago here[2], and had the code, but never got around to posting this online. The usage instruction

Fields not displaying in the admin interface

2008-01-05 Thread shabda
I have an app, and that app is included in the installed_apps in settings.py. Whn I run manage.py runserver, tables referred in the app are created. However none of the entities in that table are displayed in the admin interface, which shows tables from contrib.sites and contrib.auth. What could I

Re: Fields not displaying in the admin interface

2008-01-05 Thread shabda
Damn, I am feeling so stupid now :( . Thanks, that was the problem! On Jan 6, 11:30 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 06-Jan-08, at 11:52 AM, shabda wrote: > > > I have an app, and that app is included in the installed_apps in > > settings.py. Whn I

How to mark a model attribute as safe?

2008-01-06 Thread shabda
I have a model attribute of type TextField, where I am storing html data. While displaying in template I do not want to escape it, and so should mark this as safe. How can I do this? I read the link at http://www.djangoproject.com/documentation/templates_python/#filters-and-auto-escaping , but tha

How to bind data to a form, and not make the validation fire

2008-01-06 Thread shabda
I have a form, to which I want to pass some data when it is first dipalyed, My form is, class EditPage(forms.Form): text = forms.CharField(widget = forms.Textarea) edit_summary = forms.CharField() In my view I bind data to this form as if request.method == 'GET': page = Page.o

Re: How to bind data to a form, and not make the validation fire

2008-01-06 Thread shabda
something like text = forms.CharField(widget = forms.Textarea, initial = self.page.text) I just can't get this to work? Any place where I can look for dynamic values to initial? On Jan 6, 2:38 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2008-01-06 at 01:32 -0800, shabda

How to refer to a class defined later in the file

2008-01-07 Thread shabda
I want to have a models.py like this, class PageRevision(models.Model): """Stores a specific revision of the page""" text = models.TextField() revision_for = models.ForeignKey(Page, related_name = 'revision_for') class Page(models.Model): """Stores the latest page, the page which

How are the ids for Django models calculated?

2008-01-11 Thread shabda
Django adds an ID field to all models by default. Some questions about that. How are the values calculated. If Django asks the DB to provide it those values, can we be sure, for all supported backends, that 1. The ids are auto incrementing, (and not just unique). 2. They start from zero. 3. The d

Re: The last records of table by using of Pagination

2008-01-11 Thread shabda
instead of q_list = ObjectPaginator(Queue.objects.all(), 20) Provide a order_by, if you would like them to be in descending order, in order when they were created have, q_list = ObjectPaginator(Queue.objects.all().order_by('-id'), 20) Or better yet have a created_on field in the model, w

Re: using newforms

2008-01-12 Thread shabda
Instead of this def __init__(self, user): profile = user.get_profile() for g in profile.groups.all(): self.GROUP_CHOICES += (g.id, g.name) super(MyForm, self) Should it not be, def __init__(self, user, *args, **kwargs): profile = user.get_profile()

Working with object paginator

2008-01-12 Thread shabda
Ove of my view function is, def recently_featured (request): featured = FeaturedPage.objects.all().order_by('-ordering') paged_featured = ObjectPaginator(featured, djikikisettings.details_per_page) try: page_num = request.GET['page'] page_num = int(page_num) except:

Re: Manually Inserting Non Field Errors in a newform

2008-01-12 Thread shabda
Override __init__ for the Form, passing it the request object and store it. Access it in .clean method. On Jan 12, 10:45 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I also just realized that the reason clean() wouldn't work when I > tried to pass it the request as an argument is simply b

Re: Inserting a date into DateField

2008-01-12 Thread shabda
_dob = request.POST['dob'] gets the string representation of dob, and so python complains as it can't find the strftime method. You need to change your code to, _dob = form_name.cleaned_data['date_attribute_name'] form.cleaned_data, gets you the canonical representation for the data type dependin

Can not login on running behind Apache, but can when on development server

2008-01-13 Thread shabda
I have a view function I am using for logging in people. When I am deploying it to Apache/Mod_python, I am unable to login, but If I am running it on the development server, I am able to login. Any pointers? (I am not using the builtin login, as I want to use newforms.) The view function is, def

Re: Can not login on running behind Apache, but can when on development server

2008-01-13 Thread shabda
orms.error, and forms.is_valid fails. On Jan 13, 11:31 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote: > What daes it mean "I am unable to login". Error aqcures, exception > raises or something else? > > On 13 янв, 18:33, shabda <[EMAIL PROTECTED]> wrote: > > > I hav

Re: Can not login on running behind Apache, but can when on development server

2008-01-14 Thread shabda
Trying to login many times in a row produced this Exception, Exception Type: SuspiciousOperation at /admin/ Exception Value: User may have tampered with session cookie. Full traceback, Traceback: File "/home/shabda/lib/python2.5/django/core/handlers/base.py" in get_res

Re: Can not login on running behind Apache, but can when on development server

2008-01-14 Thread shabda
But If it were so how would running it from the development server allow me to login? On Jan 14, 5:13 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 14-Jan-08, at 5:40 PM, shabda wrote: > > > Exception Type: SuspiciousOperation at /admin/ > > Exception Value: Use

Re: Problem with Css and django template

2008-01-15 Thread shabda
You need to change this line type="text/css" href="testing1.css" /> to type="text/css" href="/static/testing1.css" /> On Jan 15, 1:00 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Jan 15, 2008 1:08 AM, laspal <[EMAIL PROTECTED]> wrote: > > This: > > > (r'^static/(?P.*)$', 'django.views.

Re: Django Performance

2008-01-15 Thread shabda
Can I > use django in a shared hosting environment or I need to buy a > Dedicated server? While many people run Django in shared hosting, IMHO, that leads to much more trouble than it is worth. But you surely do not need a dedicated server for running django. I use Webfaction, and they are one of

Re: Django Performance

2008-01-15 Thread shabda
Umm yes, I just meant that you get a own apache, and python instance, and can customise it. On Jan 15, 11:17 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > shabda wrote: > >> use django in a shared hosting environment or I need to buy a > >> Dedicated server? > >

Unable to find custom filters

2008-01-16 Thread shabda
I want to use some custom filters, and so I am using the steps given at http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters What I did was, 1. Created a templatetags directory under th app and created __init__.py, myfilters.py under it. Its structure is l

Re: Unable to find custom filters

2008-01-16 Thread shabda
I also have added this to __init__.py __all__ = ['myfilters'] On Jan 16, 9:31 pm, shabda <[EMAIL PROTECTED]> wrote: > I want to use some custom filters, and so I am using the steps given > athttp://www.djangoproject.com/documentation/templates_python/#writing-... &

Re: Unable to find custom filters

2008-01-16 Thread shabda
t2/', include('test2.foo.urls')), (r'^$','index'), the index function is being called. On Jan 16, 9:54 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Jan 16, 2008 11:31 AM, shabda <[EMAIL PROTECTED]> wrote: > > > > > &g

Re: Loading Template

2008-01-17 Thread shabda
Save yourself the trouble of writing a view function and use the generic view direct_to_template http://www.djangoproject.com/documentation/generic_views/#django-views-generic-simple-direct-to-template On Jan 17, 12:50 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Jan 17, 2008 2:32 AM, laspa

manage.py dbshell not working

2008-01-19 Thread shabda
I am trying to use the manage.py dbshell call. I give the command, F:\djangoprojects\polls>manage.py dbshell This is giving me an error like F:\djangoprojects\polls> ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) However in my settings.py I have set the user an

Re: filtering on a date field's component; a bug?

2008-01-22 Thread shabda
You have two underscores after start_date in start_date__month, probably that is the problem. Change this to start_date_month, (one underscore) and see if it works. On Jan 22, 2:15 pm, omat <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a model with a date field. When I try to filter based on it

How to apply a class to a specific field's label in newforms

2008-01-22 Thread shabda
I want to have the one of the field for my form have a specific css class. But if I do something like, widget = forms.TextInput(attrs = {'size':60, 'class':'main'} The textInput, and not its associated label gets the class. How can I specify the class for label? --~--~-~--~~---

Re: How to apply a class to a specific field's label in newforms

2008-01-22 Thread shabda
Jan 22, 5:23 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 22-Jan-08, at 5:45 PM, shabda wrote: > > > I want to have the one of the field for my form have a specific css > > class. But if I do something like, > > widget = forms.TextInput(attrs = {'size

Getting string index out of range error on using DateField

2008-01-22 Thread shabda
I have field in a form like, foo = forms.DateField(required = False, input_formats = '%m/%d/%Y') Now when I try to enter a date like 10/25/2006 I am getting an error string index out of range . Full stack trace, Traceback: File "C:\Python24\lib\site-packages\django\core\handlers\base.py" in get_r

Re: Tutorial03: question about efficiency

2008-01-22 Thread shabda
This is the right way to do so. Querysets are lazy. Only the rows needed will be fetched in this example. code_berzerker wrote: > theres line of code in tutorial: > > Poll.objects.all().order_by('-pub_date')[:5] > > this gives 5 Poll objects. I wonder if this is efficient way of > getting them? D

Striped tables in Django

2008-01-22 Thread shabda
Does anybody have a code snippet for getting striped tables with django? Basically I would need to apply alternating classes to the the rows returned by the rowset. I do not want to do this from javascript, but from server side. --~--~-~--~~~---~--~~ You received th

How to use newforms ChoiceField to show dynamic choices

2008-01-24 Thread shabda
I want to use the ChoiceField to show choices depending on a query set. For exmple the ChoiceField must get all active Users and them show them in a drop down, something like what happens in Admin. How can I do that? --~--~-~--~~~---~--~~ You received this message b

How to get sum of fields without using custom SQL?

2008-01-24 Thread shabda
My model is something like this, class Job(models.Model): name = models.CharField(...) class Entry(models.Model): job = models.ForeignKey(Job) hrs_worked = models.IntegerField() Now I want to get the sum of the hours worked in a job which I can get by summing Entries for that job. somet

Finding details of a Model object, which do not have objects of a given M2M field

2008-01-26 Thread shabda
I have the model like, class Blog(models.Model): url = models.URLField() class Entry(models.Model): blog = models.ForeignKey(Blog) user = models.ManyToManyField(User) User is contrib.auth.db.USER Now I given a blog and a user I need to find out all the Entry objects which are a det

Re: Finding details of a Model object, which do not have objects of a given M2M field

2008-01-26 Thread shabda
(user__ne=some_uesr) > > On Jan 26, 6:14 am, shabda <[EMAIL PROTECTED]> wrote: > > > I have the model like, > > > class Blog(models.Model): > > url = models.URLField() > > > class Entry(models.Model): > > blog = models.ForeignKey(Blog) > >

django-queue-service documentation

2008-01-26 Thread shabda
I want to use django-queue-service to run long running processess in background, but I can not find any documentation about this. Their website http://code.google.com/p/django-queue-service/ does not contain any docs. Does any one have any links, about how to use it? --~--~-~--~~--

Getting Out of range value adjusted for column 'created_on' at row 1

2008-01-26 Thread shabda
When trying to save a model object I get an error saying, This is the line, which is causing the error. If I remove this line and add null + True to created_on firld I do not get the exception. The traceback is at, http://dpaste.com/32727/ --~--~-~--~~~---~--~~ Yo

Re: Getting Out of range value adjusted for column 'created_on' at row 1

2008-01-26 Thread shabda
on field I do not get the exception. The traceback is at, http://dpaste.com/32727/ On Jan 27, 12:26 pm, shabda <[EMAIL PROTECTED]> wrote: > When trying to save a model object I get an error saying, > > This is the line, which is causing the error. If I remove this line > and a

Re: best configuration options for background processes

2008-01-27 Thread shabda
http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/ On Jan 28, 12:39 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'd like to run a few background processes on my server. > > They need access to the models in my app, the database, and the whole > django framework. > > Othe

Announce: 7days7apps.com

2008-01-27 Thread shabda
you use them for learning or in a production setting be sure to let me know. And if you got a few seconds, can you tell me your opinion at http://day4.7days7apps.com/poll/Does-7days7apps-suck/ Thanks, Shabda --~--~-~--~~~---~--~~ You received this message because you

Using guids wih mysql

2008-02-03 Thread shabda
I want to use guids instead of auto incrementing keys with my models for primary keys. I am using mysql. Using the UUID funcion in mysql I can do this, but is there a simpler way? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Goog

Specifying custom upload to with FileField

2008-02-06 Thread shabda
I have a model like class ProjectFile(models.Model): project = models.ForeignKey(Project) file = models.FileField(upload_to = '/files/') class Project(models.Model): name = models.CharField(max_length = 100) With this the uploaded files will go to <>/files/, howeverI want to upload a

Subclassing forms.CharField so that it gets a widget.

2008-02-07 Thread shabda
I want to subclass CharField so that, its has a widget, and I do not always need to set it. So I do class DojoCharField(forms.CharField): def __init__(self, *args, **kwargs): super(DojoCharField, self).__init__(*args, **kwargs) if self.widget == None: self.widget =

Re: Subclassing forms.CharField so that it gets a widget.

2008-02-07 Thread shabda
idget'): kwargs.update({'widget' : forms.TextInput(attrs={'dojoType':'dijit.form.TextBox'})}) super(DojoCharField, self).__init__(*args, **kwargs) or some thing similar. On Feb 8, 12:32 am, shabda <[EMAIL PROTECTED]> wrote: > I want to subclass CharField

Re: Creating password protected RSS feeds

2008-02-11 Thread shabda
This seems very useful! Is there some way I can wrap my rss feed within a view function? My feeds class looks like, class ProjectRss(Feed): def get_object(self, bits): I am using the django.contrib.syndication.feeds. Michael Elsdörfer wrote: > > How can I create passwords prot

Creating password protected RSS feeds

2008-02-11 Thread shabda
How can I create passwords protected feeds with Django? I guess I will have to go beyond the contrib.feeds framework, but if some one has any recipes/links to how to do this, it would be most helpful! --~--~-~--~~~---~--~~ You received this message because you are s

Using property() with model attributes

2008-02-11 Thread shabda
I have a model something like, class Task(models.Model): name = models.CharField() parent_task = models.ForeignKey('Task') is_complete = models.BooleanField() class TaskItem(models.Model) name = models.CharField() task = models.ForeignKey(Task) is_complete = models.BooleanField() I

Re: newforms-admin inlines question

2008-02-11 Thread shabda
I dunno if this is the answer you are looking for, but if you want to enforce that there is only one user set unique = True for the user in the UserProfile class. class UserProfile(models.Model): user = models.ForeignKey(User, unique = True) On Feb 11, 10:42 am, Aaron Fay <[EMAIL PROTECTED]> w

Raising exception when a template objects is not present or raise s exception.

2008-02-12 Thread shabda
I want my template to raise exception, when an object is not preset or raises a exception. I am sure there is a setting for it, I just cant figure out where. Help? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Djan

Newfroms - How to get the id for a field

2008-02-14 Thread shabda
When using newforms, I want to get the id set on the input field. I am doing something like, {% for field in form %} {{ field }} ... Now this {{field}} will render as something like, Withing the template how can I access the value for id. If this is not possible where in code does Django set th

Re: Setting request.GET when sending an HttpResponse

2008-02-14 Thread shabda
Umm, if you want to persist state across HTTP requests, why not use session? On Feb 14, 2:28 pm, mario <[EMAIL PROTECTED]> wrote: > Etienne, thanks for answering, > > > I believe you got this wrong a little. A HttpResponse object doesn't modify > > the query string. That should be done in your fo

How to use filefield, and specify custom, dynamic upload_to

2008-02-17 Thread shabda
I have a model like class File(models.Model): file = models.FileField(upload_to = 'files') project = models.ForeignKey(Project) class Project(models.Model): name = models.CharField(max_length = 100) I want to have each file go a specific directory corresponding to its project_name So I w

Converting relational data to hiechical data

2008-02-21 Thread shabda
I have a model like class Task(models.Model): name = Models.CharField(max_length = 100) parent = models.ForeignKey('Task', null = True) Using this model say I have got a table like, Task --- ID Name Parent_id 1 Foo null 2 Bar 1 3 Baz1 4 Bax2 I want to disp

How to stop validations duplications in forms and models?

2008-02-21 Thread shabda
I have some models, and some forms to write data to them. The attributes in models need to have soem validations, (For example, name must be alpha numeric, price must be less that 1000 etc). SO I write the validations in model.save() and raise Exceptions, when a validation fails. I also need to wr

Re: Evaluating/stepping through sliced QuerySets

2008-02-21 Thread shabda
There is a threaded comments app http://code.google.com/p/django-threadedcomments/ , Now that I think about it, they surely would be doing this conversion from relational to hierarchical format. I will read the code and let you know if I can find something useful. On Feb 20, 7:10 pm, Evert Rol <

Re: Converting relational data to hiechical data

2008-02-21 Thread shabda
That would help once I get the relational data to a hierarchical list, and that is the difficult part! On Feb 21, 10:59 pm, Brian Luft <[EMAIL PROTECTED]> wrote: > http://www.djangoproject.com/documentation/templates/#unordered-list > > On Feb 21, 4:22 am, shabda <[EMAIL

Re: How to stop validations duplications in forms and models?

2008-02-21 Thread shabda
>(the save() method shouldn't raise >any validation errors except those triggered by the database server due >to IntegrityErrors). So what is the recommended place to write validations in models, for now? On Feb 22, 12:25 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-02-21 at

How to use pychecker with Django

2008-02-21 Thread shabda
I want to use pychecker to do static analysis on my code. So I set up DJAGO_SETTINGS_MODULE and run pychecker from shell. I am getting exceptions like, G:\prajact>pychecker project\urls.py G:\prajact>C:\Python24\python.exe C:\Python24\Lib\site-packages \pychecker\checker.py project\urls.py Proce

django.test.client.Client returns HttpResponse/ How to make the test client follow 302 status codes?

2008-02-22 Thread shabda
I have some test code written like, def testDashBoard(self): c = Client() print c.login(username = 'Shabda', password= 'shabda') response = c.get('/dashboard/') print response.headers[

Re: django.test.client.Client returns HttpResponse/ How to make the test client follow 302 status codes?

2008-02-22 Thread shabda
Aww, I seems a call to c.get('/dashboard/') gets an object of type HttpResponse while c.get('/dashboard/', {}) gets a Response object. On Feb 22, 11:50 pm, shabda <[EMAIL PROTECTED]> wrote: > I have some test code written like, > > def testDashBoard(self): >

Re: django.test.client.Client returns HttpResponse/ How to make the test client follow 302 status codes?

2008-02-22 Thread shabda
Please ignore the previous message. I think I am too sleepy now, and am seeing things which do not exist. :) . On Feb 22, 11:57 pm, shabda <[EMAIL PROTECTED]> wrote: > Aww, I seems a call to c.get('/dashboard/') gets an object of type > HttpResponse while c.get('/dashb

How to compare between two attributes of the model?

2008-02-22 Thread shabda
I have a model like, class Project(models.Model): name = models.CharField() expected_start_date = models.DateField() actual_start_date = models.DateField() I want to translate the SQL query, SELECT * FROM project WHERE expected_start_date > actual_start_date, I cant do something like P

File uploads with django - memory usage questions

2008-02-23 Thread shabda
I have a form which allows users to upload files. The form is, class AddFileForm(forms.Form): """Add a file.""" filename = forms.FileField() I am using S3 to store files, my view is something like, if request.method == 'POST': addfileform = bforms.AddFileForm(request.POST, r

  1   2   3   >