diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
index c1fc979..341b46e 100644
a
|
b
|
class RelatedFieldListFilter(FieldListFilter):
|
148 | 148 | field, request, params, model, model_admin, field_path) |
149 | 149 | |
150 | 150 | other_model = get_model_from_relation(field) |
151 | | if isinstance(field, (models.ManyToManyField, |
152 | | models.related.RelatedObject)): |
153 | | # no direct field on this model, get name from other model |
154 | | self.lookup_title = other_model._meta.verbose_name |
| 151 | if hasattr(field, 'verbose_name') and field.verbose_name != u'': |
| 152 | self.lookup_title = field.verbose_name |
155 | 153 | else: |
156 | | self.lookup_title = field.verbose_name # use field name |
| 154 | self.lookup_title = other_model._meta.verbose_name |
157 | 155 | rel_name = other_model._meta.pk.name |
158 | 156 | self.lookup_kwarg = '%s__%s__exact' % (self.field_path, rel_name) |
159 | 157 | self.lookup_kwarg_isnull = '%s__isnull' % (self.field_path) |
diff --git a/tests/regressiontests/admin_filters/models.py b/tests/regressiontests/admin_filters/models.py
index 80d54c7..beb0089 100644
a
|
b
|
from django.contrib.auth.models import User
|
4 | 4 | class Book(models.Model): |
5 | 5 | title = models.CharField(max_length=50) |
6 | 6 | year = models.PositiveIntegerField(null=True, blank=True) |
7 | | author = models.ForeignKey(User, related_name='books_authored', blank=True, null=True) |
8 | | contributors = models.ManyToManyField(User, related_name='books_contributed', blank=True, null=True) |
| 7 | author = models.ForeignKey(User, verbose_name='author_verbose', related_name='books_authored', blank=True, null=True) |
| 8 | contributors = models.ManyToManyField(User, verbose_name='contributors_verbose', related_name='books_contributed', blank=True, null=True) |
9 | 9 | is_best_seller = models.NullBooleanField(default=0) |
10 | 10 | date_registered = models.DateField(null=True) |
11 | 11 | |
diff --git a/tests/regressiontests/admin_filters/tests.py b/tests/regressiontests/admin_filters/tests.py
index 7717984..c1c0b52 100644
a
|
b
|
class ListFiltersTests(TestCase):
|
232 | 232 | |
233 | 233 | # Make sure the last choice is None and is selected |
234 | 234 | filterspec = changelist.get_filters(request)[0][1] |
235 | | self.assertEqual(force_unicode(filterspec.title), u'author') |
| 235 | self.assertEquals(force_unicode(filterspec.title), u'author_verbose') |
236 | 236 | choices = list(filterspec.choices(changelist)) |
237 | 237 | self.assertEqual(choices[-1]['selected'], True) |
238 | 238 | self.assertEqual(choices[-1]['query_string'], '?author__isnull=True') |
… |
… |
class ListFiltersTests(TestCase):
|
242 | 242 | |
243 | 243 | # Make sure the correct choice is selected |
244 | 244 | filterspec = changelist.get_filters(request)[0][1] |
245 | | self.assertEqual(force_unicode(filterspec.title), u'author') |
| 245 | self.assertEquals(force_unicode(filterspec.title), u'author_verbose') |
246 | 246 | # order of choices depends on User model, which has no order |
247 | 247 | choice = select_by(filterspec.choices(changelist), "display", "alfred") |
248 | 248 | self.assertEqual(choice['selected'], True) |
… |
… |
class ListFiltersTests(TestCase):
|
260 | 260 | |
261 | 261 | # Make sure the last choice is None and is selected |
262 | 262 | filterspec = changelist.get_filters(request)[0][2] |
263 | | self.assertEqual(force_unicode(filterspec.title), u'user') |
| 263 | self.assertEquals(force_unicode(filterspec.title), u'contributors_verbose') |
264 | 264 | choices = list(filterspec.choices(changelist)) |
265 | 265 | self.assertEqual(choices[-1]['selected'], True) |
266 | 266 | self.assertEqual(choices[-1]['query_string'], '?contributors__isnull=True') |
… |
… |
class ListFiltersTests(TestCase):
|
270 | 270 | |
271 | 271 | # Make sure the correct choice is selected |
272 | 272 | filterspec = changelist.get_filters(request)[0][2] |
273 | | self.assertEqual(force_unicode(filterspec.title), u'user') |
| 273 | self.assertEquals(force_unicode(filterspec.title), u'contributors_verbose') |
274 | 274 | choice = select_by(filterspec.choices(changelist), "display", "bob") |
275 | 275 | self.assertEqual(choice['selected'], True) |
276 | 276 | self.assertEqual(choice['query_string'], '?contributors__id__exact=%d' % self.bob.pk) |
… |
… |
class ListFiltersTests(TestCase):
|
471 | 471 | self.assertEqual(choices[3]['query_string'], '?publication-decade=the+00s&author__id__exact=%s' % self.alfred.pk) |
472 | 472 | |
473 | 473 | filterspec = changelist.get_filters(request)[0][0] |
474 | | self.assertEqual(force_unicode(filterspec.title), u'author') |
| 474 | self.assertEquals(force_unicode(filterspec.title), u'author_verbose') |
475 | 475 | choice = select_by(filterspec.choices(changelist), "display", "alfred") |
476 | 476 | self.assertEqual(choice['selected'], True) |
477 | 477 | self.assertEqual(choice['query_string'], '?publication-decade=the+00s&author__id__exact=%s' % self.alfred.pk) |