Opened 11 years ago
Closed 11 years ago
#21918 closed Uncategorized (invalid)
Ordering changing order_by behavior
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.5 |
Severity: | Normal | Keywords: | ordering |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Not sure if its a bug, but i am having this problem:
models.py
class Year(models.Model): year = models.IntegerField(unique=True) class Meta: ordering = ['-year']
views.py
def list_years(request): year = Year.objects.all().order_by('-year') ...
The problem is that the order_by is returning ascending probably because of the ordering from the meta class. In my opinion the order_by should not be affected by the ordering attribute from the meta class for clarity.
Change History (2)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Sorry, had some problems in my application that did this. Closing...
Note:
See TracTickets
for help on using tickets.
Do you get different ordering for the
Year.objects.all().order_by('-year')
query if you remove the Meta ordering attribute? If I recall correctly this shouldn't happen.