Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#13490 closed (invalid)

Django's `order_by` Performs Differently Based on Environment

Reported by: b14ck Owned by: nobody
Component: Uncategorized Version: dev
Severity: Keywords: database, query, order_by, inconsistency
Cc: rdegges@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi there. I came across the following (seemingly) inconsistency with Django's order_by method, that is usually used on DB queries. It appears to act differently when used in production vs. when used through python manage.py shell:

# from python manage.py shell

rdegges@WEB01:~/partyline_portal$ python manage.py shell
Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from partyline_portal.partylines.models import Partyline
>>> partylines = Partyline.objects.all()
>>> partylines
[<Partyline: Randall Test>]
>>> partylines = Partyline.objects.all().order_by('name')
>>> partylines
[<Partyline: Randall Test>]
>>> partylines = Partyline.objects.all()
>>> partylines
[<Partyline: Randall Test>]
>>> partylines.order_by('name')
[<Partyline: Randall Test>]
>>>

As you can see above, I can use the order_by function on both queries: Partyline.objects.all().order_by('name') as well as lists: partylines.order_by('name')

However, if I run this same code in a view, and render a page to the user, Django spits an error saying that partylines has no method order_by available to it.

Change History (2)

comment:1 by Russell Keith-Magee, 14 years ago

Resolution: invalid
Status: newclosed

I can't find any evidence that this is happening. A queryset is a queryset, and querysets have an order_by method. You haven't provided sample view code; I can only presume that your view has an error of some kind.

comment:2 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top