Re: sorting by date – problem handling/ordering nu ll values

2010-04-10 Thread ARie
okay, it actually wasn't that hard. just in case anyone faces the same situation here the solution that works for me: tickets.extra(select={'has_deadline': "CASE WHEN myDeadline IS NULL THEN 1 ELSE 0 END"}).order_by('has_deadline','myDeadline') -- You received this message because you are

Re: Is the DoesNotExist exception the only way to check if an object exists?

2010-04-10 Thread Matt Schinckel
On Apr 10, 8:30 am, Kevin Teague wrote: > There is nothing exceptional about exceptions in Python. McDonc does a > good job at explaining how to think about exceptions as less than > exceptional: > > http://plope.com/Members/chrism/exceptions_arent_errors/view > > The only arguably

Re: Is the DoesNotExist exception the only way to check if an object exists?

2010-04-10 Thread Daniel Roseman
On Apr 9, 10:54 pm, Joakim Hove wrote: > Hello, > > I have something I would presume was a very common pattern. I have a > view which gets a primary-key (from the user) as second argument: > > def my_view( request , pk ): >      obj = Class.objects.get( pk = pk) >      # Do

filter records of one table depending on other table

2010-04-10 Thread Jitesh
Hi all, I am having two tables say TableOne and TableTwo and below are some of the fields of these tables TableOne: companyName Tabletwo: companyid (i am saving key().id() of TableOne in it) now i have to filter TableOne contents which are not in TableTwo. i.e. i want list of companies which

the most efficient way to remove item from a table with self referencing foreign key

2010-04-10 Thread mouadino
Hello everybody I have a model with self reference foreign key : class Categories(Model.model): category = Model.CharField(...) parent_category = Model.ForeignKey(self, ...) url = Model.CharField() an i want to remove items from this table given the url of a category this is a

[django] automatically loading initial data fixtures for third party apps

2010-04-10 Thread Andreo
Hi all, I want to provide automatically loaded initial data for the third party app - 'django-tagging'. There is a special place for internal apps: /fixtures/initial_data.yaml, but not for a third party. I want data to bi initialized on ./manage.py syncdb There are many similar questions:

[django] dumping data in utf-8

2010-04-10 Thread Andreo
I dump datga: ./manage.py dumpdata --format=yaml appname > initial_data.yaml The result is: - fields: {description: "\u0423\u043A\u0440\u0430\u0438\u0301\u043D \u0430 (\u0443\ \u043A\u0440. \u0423\u043A\u0440\u0430\u0457\u043D\u0430 [ukr\u0251\u02C8\ How to configure django to save

Re: Is the DoesNotExist exception the only way to check if an object exists?

2010-04-10 Thread greatlemer
This can work when you know you want to use the object once it's been retrieved. If all you want to do is check for existence then it's better to do the check with a: if Class.objects.filter(pk=pk).count() == 0: # Do object doesn't exist stuff else: # Do object does exist stuff -- G On

Re: Giving up PHP. ...Can't decide between Django & Rails

2010-04-10 Thread Wiiboy
I'm a bit of a noob as well, and know nothing about Rails, but I'd like to comment on a few issues you mentioned. 1. Non-existent template variables are replaced with the value of the TEMPLATE_STRING_IF_INVALID setting. Set that to something besides its default (an empty string) to make

Dynamic forms through a class factory; 'string index out of range'

2010-04-10 Thread Laereom
As the title suggests, I'm creating a dynamic form via a class factory. Here is what I'm doing inside the class factory itself (as far as actually making the class goes): class _QuestionAnswerForm(forms.Form): response =

Re: Giving up PHP. ...Can't decide between Django & Rails

2010-04-10 Thread Torsten Bronger
Hallöchen! Wiiboy writes: > [...] > > 2. Regarding documentation, the docs at > http://docs.djangoproject.com are, in my opinion, simply amazing. > By far the best documentation for a free project that I've seen > (but then again, I haven't seen much). [...] They are great. Really great. And

Re: Dynamic forms through a class factory; 'string index out of range'

2010-04-10 Thread Daniel Roseman
On Apr 10, 4:40 pm, Laereom wrote: > As the title suggests, I'm creating a dynamic form via a class > factory. > > Here is what I'm doing inside the class factory itself (as far as > actually making the class goes): >                 class _QuestionAnswerForm(forms.Form):

Re: Baffled by self.client.login(...) not working in unit tests

2010-04-10 Thread adambossy
I forgot to mention: I'm using Django 1.0 on Ubuntu. On Apr 9, 10:41 pm, adambossy wrote: > I have created users for my unit tests in two ways: > > 1) Create a fixture for "auth.user" that looks roughly like this: > >     { >         "pk": 1, >         "model": "auth.user",

Re: Dynamic forms through a class factory; 'string index out of range'

2010-04-10 Thread Laereom
Honestly, I really don't like that method, mostly due to ugliness. I'm looking for a solution specifically to instantiating a form created via a class factory, unless that is some sort of Herculean task. On Apr 10, 10:13 am, Daniel Roseman wrote: > On Apr 10, 4:40 pm,

Re: Dynamic forms through a class factory; 'string index out of range'

2010-04-10 Thread Laereom
Scratch that. I ended up doing it the other way. I went back and reviewed and it seemed less ugly now than it did at midnight last night. Funny, that. Thanks for the advice. On Apr 10, 10:45 am, Laereom wrote: > Honestly, I really don't like that method, mostly due to

LogEntry change messages do not do i18n properly

2010-04-10 Thread stereoit
Hi, today I've noticed that my LogEntry change messages output the name of the field and do not respect when it has verbose_name setup (which is translated). I've had a look at admin.options.construct_change_message(), the line responsible is: change_message.append(_('Changed %s.') %

Re: ValidationError: ManagementForm data is missing or has been tampered with

2010-04-10 Thread Gramware
Try this for a solution http://stackoverflow.com/questions/2536285/django-formset-management-form-validation-error -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To

Possible reasons why a session variable would be cleared out between POST requests?

2010-04-10 Thread Daniel
Hi there, I have a request.session['querySoFar'] variable that I'm appending a Q object to with each POST in order to build up a final query to run. However, this session var is getting cleared out sometimes. I have no idea why this is happening. I do not believe that I am resetting like so:

code repetition in views

2010-04-10 Thread ydjango
I find all my view method have identical code in start and in end: anyway to avoid repetition...? Example: def typical_view_method(request): Check if user is authenticated. Get user and group Get some session variables try: Method specific logic except Exception, e: