Code

Opened 8 years ago

Closed 6 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: master
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

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 8 years ago.
allow_ascending.diff (4.3 KB) - added by cogat 6 years ago.

Download all attachments as: .zip

Change History (9)

Changed 8 years ago by noods

comment:1 Changed 8 years ago by noods

  • Summary changed from add ascending sort option to date_based generic views to [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 Changed 8 years ago by noods

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 Changed 8 years ago by adrian

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

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

comment:4 Changed 6 years ago by cogat

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

Changed 6 years ago by cogat

comment:5 Changed 6 years ago by cogat

  • Needs documentation set
  • Needs tests set
  • Resolution wontfix deleted
  • Status changed from closed to reopened

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 Changed 6 years ago by PJCrosier

  • Summary changed from [patch] add ascending sort option to date_based generic views to Add ascending sort option to date_based generic views

comment:7 Changed 6 years ago by jacob

  • Resolution set to wontfix
  • Status changed from reopened to closed

Wontfixing again - see Adrian's comment.

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.