Opened 10 years ago

Closed 9 years ago

Last modified 7 years ago

#3134 closed defect (fixed)

[patch] The archive_year date-based generic view should not override a model's default ordering

Reported by: matt.riggott@… Owned by: Jacob
Component: Generic views Version: master
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: UI/UX:

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)

archive_year.patch (1.8 KB) - added by Matt 10 years ago.
Patch to add order_by parameter to the archive_year generic view; also adds documentation for the parameter.

Download all attachments as: .zip

Change History (10)

Changed 10 years ago by Matt

Attachment: archive_year.patch added

Patch to add order_by parameter to the archive_year generic view; also adds documentation for the parameter.

comment:1 Changed 10 years ago by anonymous

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 Changed 10 years ago by ramiro <rm0 _at_ gmx.net>

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 Changed 10 years ago by matt.riggott@…

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 Changed 10 years ago by paolo@…

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 Changed 10 years ago by Gary Wilson <gary.wilson@…>

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 Changed 10 years ago by Gary Wilson <gary.wilson@…>

Cc: gary.wilson@… added

comment:7 Changed 10 years ago by (none)

milestone: Version 1.0

Milestone Version 1.0 deleted

comment:8 Changed 10 years ago by Gary Wilson <gary.wilson@…>

Triage Stage: UnreviewedDesign decision needed

comment:9 Changed 9 years ago by Gary Wilson

Resolution: fixed
Status: newclosed

(In [6057]) Fixed #3134 -- Made the archive_year generic view consistent with the other date-based generic views by not performing an order_by() on the passed queryset. This change is backwards-incompatible if you were relying on archive_year to do the ordering for you.

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