diff options
| author | Klemens Mantzos <klemens@fetzig.at> | 2014-01-23 03:13:59 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-02-14 19:53:44 -0500 |
| commit | f683cb90bea2afbe0ef4c011acd4ab590c37410d (patch) | |
| tree | fdb2b7528378f60979fd5e32a27ae80594626962 /django | |
| parent | 0242134d32aa99a54442211ed05576b7061866d1 (diff) | |
Fixed #21924 -- Added the ability to specify a reverse order for admin_order_field.
Thanks Klemens Mantzos for the report and initial patch.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/views/main.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index dccab55de4..c22225927c 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -293,7 +293,11 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)): order_field = self.get_ordering_field(field_name) if not order_field: continue # No 'admin_order_field', skip it - ordering.append(pfx + order_field) + # reverse order if order_field has already "-" as prefix + if order_field.startswith('-') and pfx == "-": + ordering.append(order_field[1:]) + else: + ordering.append(pfx + order_field) except (IndexError, ValueError): continue # Invalid ordering specified, skip it. |
