Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 1e70426619ea512e6792a5b5adf6740fa8fb1cc6 1 parent 9eada8a
Jacob Kaplan-Moss authored May 22, 2007
6  django/contrib/admin/templatetags/admin_list.py
@@ -72,6 +72,7 @@ def result_headers(cl):
72 72
     for i, field_name in enumerate(lookup_opts.admin.list_display):
73 73
         try:
74 74
             f = lookup_opts.get_field(field_name)
  75
+            admin_order_field = None
75 76
         except models.FieldDoesNotExist:
76 77
             # For non-field list_display values, check for the function
77 78
             # attribute "short_description". If that doesn't exist, fall
@@ -86,7 +87,8 @@ def result_headers(cl):
86 87
                     header = field_name.replace('_', ' ')
87 88
 
88 89
             # It is a non-field, but perhaps one that is sortable
89  
-            if not getattr(getattr(cl.model, field_name), "admin_order_field", None):
  90
+            admin_order_field = getattr(getattr(cl.model, field_name), "admin_order_field", None)
  91
+            if not admin_order_field:
90 92
                 yield {"text": header}
91 93
                 continue
92 94
 
@@ -101,7 +103,7 @@ def result_headers(cl):
101 103
 
102 104
         th_classes = []
103 105
         new_order_type = 'asc'
104  
-        if field_name == cl.order_field:
  106
+        if field_name == cl.order_field or admin_order_field == cl.order_field:
105 107
             th_classes.append('sorted %sending' % cl.order_type.lower())
106 108
             new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()]
107 109
 

0 notes on commit 1e70426

Please sign in to comment.
Something went wrong with that request. Please try again.