#9415: QuerySet.order_by() should be chainable
------------------------------------------+---------------------------------
Reporter: Tarken | Owner: nobody
Status: new | Milestone:
Component: Database layer (models, ORM) | Version: 1.0
Keywords: | Stage: Unreviewed
Has_patch: 0 |
------------------------------------------+---------------------------------
I have a case where it would be very convenient to be able to call
order_by() multiple times, appending to the order by clause with each
successive call; i.e.,
{{{
#!python
foo = Model.objects.all().order_by('field1')
if bar:
foo = foo.order_by('-field2')
}}}
Currently, the second call to order_by() explicitly overrides the previous
order. This is not the behavior I would expect, as most (all?) other
methods on a QuerySet are chainable.
If it is decided that chaining will not be allowed with order_by(), then I
think that this fact should at least be documented. Had I not been
printing out my connection's queries when I ran into this problem, it may
have taken me some time to figure out exactly what was going on.
--
Ticket URL: <http://code.djangoproject.com/ticket/9415>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---