Opened 18 years ago

Closed 17 years ago

#2450 closed enhancement (wontfix)

Add ascending sort option to date_based generic views

Reported by: noods Owned by: Jacob
Component: Generic views Version: dev
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It would be nice to have the ability to change the sort order of objects in date_based generic views. With the new addition of the allow_future option it makes sense to be able to sort by ascending date order instead of the default descending order.

For example in an event calendar you want to show upcoming events first.

Attachments (2)

sort.patch (1005 bytes ) - added by noods 18 years ago.
allow_ascending.diff (4.3 KB ) - added by Greg Turner 17 years ago.

Download all attachments as: .zip

Change History (9)

by noods, 18 years ago

Attachment: sort.patch added

comment:1 by noods, 18 years ago

Summary: add ascending sort option to date_based generic views[patch] add ascending sort option to date_based generic views

I should clarify slightly, I'm talking about the archive_index view and changing the sort order of the "latest" objects.

comment:2 by noods, 18 years ago

After some thought I'm not sure this is necessary. I can just as easily just use an object_list generic view to get whichever objects I want in whatever order - the only thing I lose is the date_list context var, which would be easy to add if I want it.

Feel free to resolve.

comment:3 by Adrian Holovaty, 18 years ago

Resolution: wontfix
Status: newclosed

Closing for the reason you pointed out in the previous comment.

comment:4 by Greg Turner, 17 years ago

Ignore my patch, intended to be an alternative - it doesn't work well with the other views.

by Greg Turner, 17 years ago

Attachment: allow_ascending.diff added

comment:5 by Greg Turner, 17 years ago

Needs documentation: set
Needs tests: set
Resolution: wontfix
Status: closedreopened

My patch is fixed, so I'll describe it:

I have a site with many date-based views which share templates, and it just turned out that some needed to be ascending and some descending. The Django way would be to let me reverse the sort order, rather than make me rewrite some of them using generic list views.

My patch allows "-" in front of the date_field parameter to reverse the order. It also works with the other date_based views (not just archive), and sorts all the views by the date field as well.

comment:6 by Pete Crosier, 17 years ago

Summary: [patch] add ascending sort option to date_based generic viewsAdd ascending sort option to date_based generic views

comment:7 by Jacob, 17 years ago

Resolution: wontfix
Status: reopenedclosed

Wontfixing again - see Adrian's comment.

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