mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #21924 -- Added the ability to specify a reverse order for admin_order_field.
Thanks Klemens Mantzos for the report and initial patch.
This commit is contained in:
committed by
Tim Graham
parent
0242134d32
commit
f683cb90be
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user