Code

Opened 7 years ago

Closed 7 years ago

#5188 closed (duplicate)

archive_index shouldn't do explicit ordering

Reported by: ubernostrum Owned by: nobody
Component: Generic views Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Currently, the date-based archive_index and archive_year (when make_object_list is True) generic views use explicit calls to order_by to re-order the QuerySet they receive. There are two problems with this:

  1. They do it inconsistently: archive_index sorts by date_field descending, while archive_year sorts by date_field ascending.
  2. In doing so, they override any ordering specified by the model or already applied to the QuerySet, reducing their flexibility.

For sake of consistency with each other and with the other date-based generic views, and to restore the flexibility of allowing the user to choose how the QuerySet will be ordered, both views should stop trying to do an explicit order_by.

Attachments (1)

generic_views_no_explicit_ordering.diff (790 bytes) - added by ubernostrum 7 years ago.
Patch which removes the order_by calls

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by ubernostrum

Patch which removes the order_by calls

comment:1 Changed 7 years ago by Simon G. <dev@…>

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

Sounds fairly sensible. Do we need to add info about the ordering to the generic views docs?

comment:2 Changed 7 years ago by mtredinnick

  • Triage Stage changed from Ready for checkin to Design decision needed

This isn't ready to commit yet. There's a genuine issue that's been raised by Gary Wilson in the related django-dev thread (the third post).

comment:3 Changed 7 years ago by gwilson

  • Summary changed from archive_year and archive_index shouldn't do explicit ordering to archive_index shouldn't do explicit ordering

Renaming ticket to just deal with archive_index, as there is already a ticket open (#3134) for archive_year (and it doesn't have the issue mentioned in the django-dev thread posted above).

comment:4 Changed 7 years ago by ubernostrum

  • Resolution set to duplicate
  • Status changed from new to closed

I'm closing this because Gary fixed archive_year in [6057] and he's right that archive_index shouldn't be changed.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.