mirror of
https://github.com/django/django.git
synced 2024-12-24 01:55:49 +00:00
Fixed #3397 (again): admin_order_field is now displayed correctly in the admin views. Thanks, kent37@tds.net
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5318 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9eada8ad62
commit
1e70426619
@ -72,6 +72,7 @@ def result_headers(cl):
|
|||||||
for i, field_name in enumerate(lookup_opts.admin.list_display):
|
for i, field_name in enumerate(lookup_opts.admin.list_display):
|
||||||
try:
|
try:
|
||||||
f = lookup_opts.get_field(field_name)
|
f = lookup_opts.get_field(field_name)
|
||||||
|
admin_order_field = None
|
||||||
except models.FieldDoesNotExist:
|
except models.FieldDoesNotExist:
|
||||||
# For non-field list_display values, check for the function
|
# For non-field list_display values, check for the function
|
||||||
# attribute "short_description". If that doesn't exist, fall
|
# attribute "short_description". If that doesn't exist, fall
|
||||||
@ -86,7 +87,8 @@ def result_headers(cl):
|
|||||||
header = field_name.replace('_', ' ')
|
header = field_name.replace('_', ' ')
|
||||||
|
|
||||||
# It is a non-field, but perhaps one that is sortable
|
# It is a non-field, but perhaps one that is sortable
|
||||||
if not getattr(getattr(cl.model, field_name), "admin_order_field", None):
|
admin_order_field = getattr(getattr(cl.model, field_name), "admin_order_field", None)
|
||||||
|
if not admin_order_field:
|
||||||
yield {"text": header}
|
yield {"text": header}
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -101,7 +103,7 @@ def result_headers(cl):
|
|||||||
|
|
||||||
th_classes = []
|
th_classes = []
|
||||||
new_order_type = 'asc'
|
new_order_type = 'asc'
|
||||||
if field_name == cl.order_field:
|
if field_name == cl.order_field or admin_order_field == cl.order_field:
|
||||||
th_classes.append('sorted %sending' % cl.order_type.lower())
|
th_classes.append('sorted %sending' % cl.order_type.lower())
|
||||||
new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()]
|
new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user