Opened 10 years ago

Closed 10 years ago

#21924 closed New feature (fixed)

added reverse order for admin_order_field

Reported by: fetzig Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: yes UI/UX: no

Description

after adding this you can setup something like this:

def age_in_years(self):
    return # age calculated via DateField self.date_of_birth
age_in_years.admin_order_field = '-date_of_birth'

the '-' at the beginning of '-date_of_birth' indicates the reverse order in the changelist.

already made a pull request here:
https://github.com/django/django/pull/2201

and patch is here:
https://github.com/fetzig/django/commit/2924431df1060d5ec1e0d2e6778b3c58cb85de05.patch

missing:

  • patch for docs
  • test(s)

won't be able to make the docs update and tests within the next week. so everybody is very welcome if you like to do that :)

Change History (6)

comment:1 by fetzig, 10 years ago

Type: UncategorizedNew feature

comment:2 by fetzig, 10 years ago

Needs documentation: set
Needs tests: set

comment:3 by fetzig, 10 years ago

Patch needs improvement: set

comment:4 by Tim Graham, 10 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

comment:5 by fabulousmuscles, 10 years ago

I added a test and documentation for this new feature.
My pull request is here: https://github.com/django/django/pull/2275
All tests pass under SQLite. This was my first time contributing to the Django project and I think I did everything correctly but if there's anything 'off' please let me know. Thanks.

comment:6 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In f683cb90bea2afbe0ef4c011acd4ab590c37410d:

Fixed #21924 -- Added the ability to specify a reverse order for admin_order_field.

Thanks Klemens Mantzos for the report and initial patch.

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