Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #15971 -- Fixed regression introduced in r16144 that prevented …

…the use of the field's verbose_name attribute. Thanks to mk and Julien.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16171 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 032b4ab5dfc39b8166d472ae5e360f985afe2988 1 parent 4d039d8
Jannis Leidel authored May 07, 2011
2  django/contrib/admin/filters.py
@@ -110,7 +110,7 @@ class FieldListFilter(ListFilter):
110 110
     def __init__(self, field, request, params, model, model_admin, field_path):
111 111
         self.field = field
112 112
         self.field_path = field_path
113  
-        self.title = field_path
  113
+        self.title = getattr(field, 'verbose_name', field_path)
114 114
         super(FieldListFilter, self).__init__(request, params, model, model_admin)
115 115
 
116 116
     def has_output(self):
14  tests/regressiontests/admin_filters/tests.py
@@ -128,7 +128,7 @@ def test_datefieldlistfilter(self):
128 128
 
129 129
         # Make sure the correct choice is selected
130 130
         filterspec = changelist.get_filters(request)[0][4]
131  
-        self.assertEqual(force_unicode(filterspec.title), u'date_registered')
  131
+        self.assertEqual(force_unicode(filterspec.title), u'date registered')
132 132
         choice = select_by(filterspec.choices(changelist), "display", "Today")
133 133
         self.assertEqual(choice['selected'], True)
134 134
         self.assertEqual(choice['query_string'], '?date_registered__day=%s'
@@ -150,7 +150,7 @@ def test_datefieldlistfilter(self):
150 150
 
151 151
         # Make sure the correct choice is selected
152 152
         filterspec = changelist.get_filters(request)[0][4]
153  
-        self.assertEqual(force_unicode(filterspec.title), u'date_registered')
  153
+        self.assertEqual(force_unicode(filterspec.title), u'date registered')
154 154
         choice = select_by(filterspec.choices(changelist), "display", "This month")
155 155
         self.assertEqual(choice['selected'], True)
156 156
         self.assertEqual(choice['query_string'], '?date_registered__month=%s'
@@ -170,7 +170,7 @@ def test_datefieldlistfilter(self):
170 170
 
171 171
         # Make sure the correct choice is selected
172 172
         filterspec = changelist.get_filters(request)[0][4]
173  
-        self.assertEqual(force_unicode(filterspec.title), u'date_registered')
  173
+        self.assertEqual(force_unicode(filterspec.title), u'date registered')
174 174
         choice = select_by(filterspec.choices(changelist), "display", "This year")
175 175
         self.assertEqual(choice['selected'], True)
176 176
         self.assertEqual(choice['query_string'], '?date_registered__year=%s'
@@ -186,7 +186,7 @@ def test_datefieldlistfilter(self):
186 186
 
187 187
         # Make sure the correct choice is selected
188 188
         filterspec = changelist.get_filters(request)[0][4]
189  
-        self.assertEqual(force_unicode(filterspec.title), u'date_registered')
  189
+        self.assertEqual(force_unicode(filterspec.title), u'date registered')
190 190
         choice = select_by(filterspec.choices(changelist), "display", "Past 7 days")
191 191
         self.assertEqual(choice['selected'], True)
192 192
         self.assertEqual(choice['query_string'], '?date_registered__gte=%s'
@@ -349,7 +349,7 @@ def verify_booleanfieldlistfilter(self, modeladmin):
349 349
 
350 350
         # Make sure the correct choice is selected
351 351
         filterspec = changelist.get_filters(request)[0][3]
352  
-        self.assertEqual(force_unicode(filterspec.title), u'is_best_seller')
  352
+        self.assertEqual(force_unicode(filterspec.title), u'is best seller')
353 353
         choice = select_by(filterspec.choices(changelist), "display", "No")
354 354
         self.assertEqual(choice['selected'], True)
355 355
         self.assertEqual(choice['query_string'], '?is_best_seller__exact=0')
@@ -363,7 +363,7 @@ def verify_booleanfieldlistfilter(self, modeladmin):
363 363
 
364 364
         # Make sure the correct choice is selected
365 365
         filterspec = changelist.get_filters(request)[0][3]
366  
-        self.assertEqual(force_unicode(filterspec.title), u'is_best_seller')
  366
+        self.assertEqual(force_unicode(filterspec.title), u'is best seller')
367 367
         choice = select_by(filterspec.choices(changelist), "display", "Yes")
368 368
         self.assertEqual(choice['selected'], True)
369 369
         self.assertEqual(choice['query_string'], '?is_best_seller__exact=1')
@@ -377,7 +377,7 @@ def verify_booleanfieldlistfilter(self, modeladmin):
377 377
 
378 378
         # Make sure the correct choice is selected
379 379
         filterspec = changelist.get_filters(request)[0][3]
380  
-        self.assertEqual(force_unicode(filterspec.title), u'is_best_seller')
  380
+        self.assertEqual(force_unicode(filterspec.title), u'is best seller')
381 381
         choice = select_by(filterspec.choices(changelist), "display", "Unknown")
382 382
         self.assertEqual(choice['selected'], True)
383 383
         self.assertEqual(choice['query_string'], '?is_best_seller__isnull=True')

0 notes on commit 032b4ab

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