Opened 5 years ago

Closed 5 years ago

#21924 closed New feature (fixed)

added reverse order for admin_order_field

Reported by: fetzig Owned by: nobody
Component: contrib.admin Version: master
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


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:

and patch is here:


  • 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 Changed 5 years ago by fetzig

Type: UncategorizedNew feature

comment:2 Changed 5 years ago by fetzig

Needs documentation: set
Needs tests: set

comment:3 Changed 5 years ago by fetzig

Patch needs improvement: set

comment:4 Changed 5 years ago by Tim Graham

Easy pickings: set
Triage Stage: UnreviewedAccepted

comment:5 Changed 5 years ago by fabulousmuscles

I added a test and documentation for this new feature.
My pull request is here:
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 Changed 5 years ago by Tim Graham <timograham@…>

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