#3134 closed defect (fixed)
[patch] The archive_year date-based generic view should not override a model's default ordering
Reported by: | Owned by: | Jacob | |
---|---|---|---|
Component: | Generic views | Version: | dev |
Severity: | minor | Keywords: | |
Cc: | gary.wilson@… | Triage Stage: | Design decision needed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The archive_month
, archive_week
, and archive_day
date-based generic views all respect a model's default ordering — that is, none of those generic views append order_by()
when they filter a QuerySet
. The archive_year
view, however, will always return a chronological list of objects; this cannot be overridden.
The offending code is line 79 (in the current Subversion trunk).
I might be wrong, but I think archive_year
should adhere to a model's default ordering, as the related date-based views do. But since this would change the expected behaviour of a lot of existing sites, I guess an optional parameter allowing a programmer to specify the ordering would be nice. I'll attach a patch.
Attachments (1)
Change History (10)
by , 18 years ago
Attachment: | archive_year.patch added |
---|
comment:1 by , 18 years ago
Summary: | The archive_year date-based generic view should not override a model's default ordering → [patch] The archive_year date-based generic view should not override a model's default ordering |
---|
comment:2 by , 18 years ago
See #3264 where another solution is proposed, would you mind writing a small comparison of both patches so the people with SVN commiting powers can review it and decide if/what to implement in trunk?. I don´t dare to mark one of both tickets as duplicate of the other ecause it will close it in the process.
comment:3 by , 18 years ago
I've marked #3264 as a duplicate of this, as I think we have the better solution here.
To compare the two: the patch at #3264 changes the archive_year
view to use the model's default ordering (thus changing the behaviour of the view); this patch offers an optional parameter to specify ordering, defaulting to the current behaviour if left blank. There are also changes to the docs attached here.
This ticket is missing unit tests though; unless anyone else provides them first I will add them when I can.
comment:4 by , 18 years ago
It'd be curious to imagine how people will motivate, from reading the docs, that none of the other date based generic views have an optional order_by parameter while archive_year instead offer this option.
comment:5 by , 18 years ago
milestone: | → Version 1.0 |
---|
Seeing how this would be a (minor) API change, setting milestone to 1.0.
discussion here:
http://groups.google.com/group/django-developers/browse_thread/thread/a9cea4ec6242cd41
comment:6 by , 18 years ago
Cc: | added |
---|
comment:8 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:9 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patch to add
order_by
parameter to thearchive_year
generic view; also adds documentation for the parameter.