Django

Code

Ticket #3134 (closed: fixed)

Opened 2 years ago

Last modified 1 year ago

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

Reported by: matt.riggott@gmail.com Assigned to: jacob
Milestone: Component: Generic views
Version: SVN Keywords:
Cc: gary.wilson@gmail.com Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

archive_year.patch (1.8 kB) - added by Matt on 12/12/06 06:29:03.
Patch to add order_by parameter to the archive_year generic view; also adds documentation for the parameter.

Change History

12/12/06 06:29:03 changed 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.

12/12/06 06:29:38 changed by anonymous

  • summary changed from The archive_year date-based generic view should not override a model's default ordering to [patch] The archive_year date-based generic view should not override a model's default ordering.

01/10/07 04:21:37 changed 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.

01/13/07 07:31:37 changed by matt.riggott@gmail.com

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.

01/13/07 08:27:53 changed by paolo@php3.it

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.

01/14/07 23:38:03 changed by Gary Wilson <gary.wilson@gmail.com>

  • milestone set to 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

01/14/07 23:38:33 changed by Gary Wilson <gary.wilson@gmail.com>

  • cc set to gary.wilson@gmail.com.

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted

01/30/07 23:26:06 changed by Gary Wilson <gary.wilson@gmail.com>

  • stage changed from Unreviewed to Design decision needed.

09/06/07 23:09:59 changed by gwilson

  • status changed from new to closed.
  • resolution set to fixed.

(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.

09/29/07 03:45:12 changed by anonymous


Add/Change #3134 ([patch] The archive_year date-based generic view should not override a model's default ordering)




Change Properties
Action