Opened 17 years ago

Closed 17 years ago

Last modified 15 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: 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)

archive_year.patch (1.8 KB ) - added by Matt 17 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)

by Matt, 17 years ago

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 by anonymous, 17 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 ramiro <rm0 _at_ gmx.net>, 17 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 matt.riggott@…, 17 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 paolo@…, 17 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 Gary Wilson <gary.wilson@…>, 17 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 Gary Wilson <gary.wilson@…>, 17 years ago

Cc: gary.wilson@… added

comment:7 by (none), 17 years ago

milestone: Version 1.0

Milestone Version 1.0 deleted

comment:8 by Gary Wilson <gary.wilson@…>, 17 years ago

Triage Stage: UnreviewedDesign decision needed

comment:9 by Gary Wilson, 17 years ago

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