diff --git a/django/contrib/admin/filterspecs.py b/django/contrib/admin/filterspecs.py
index d887af2..f017512 100644
a
|
b
|
class RelatedFilterSpec(FilterSpec):
|
68 | 68 | f, request, params, model, model_admin, field_path=field_path) |
69 | 69 | |
70 | 70 | other_model = get_model_from_relation(f) |
71 | | if isinstance(f, (models.ManyToManyField, |
72 | | models.related.RelatedObject)): |
73 | | # no direct field on this model, get name from other model |
74 | | self.lookup_title = other_model._meta.verbose_name |
| 71 | if hasattr(f, 'verbose_name') and f.verbose_name != u'': |
| 72 | self.lookup_title = f.verbose_name |
75 | 73 | else: |
76 | | self.lookup_title = f.verbose_name # use field name |
| 74 | self.lookup_title = other_model._meta.verbose_name |
77 | 75 | rel_name = other_model._meta.pk.name |
78 | 76 | self.lookup_kwarg = '%s__%s__exact' % (self.field_path, rel_name) |
79 | 77 | self.lookup_kwarg_isnull = '%s__isnull' % (self.field_path) |
diff --git a/tests/regressiontests/admin_filterspecs/models.py b/tests/regressiontests/admin_filterspecs/models.py
index fe9fdfe..cea88d0 100644
a
|
b
|
from django.contrib.auth.models import User
|
4 | 4 | class Book(models.Model): |
5 | 5 | title = models.CharField(max_length=25) |
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 | |
10 | 10 | def __unicode__(self): |
11 | 11 | return self.title |
diff --git a/tests/regressiontests/admin_filterspecs/tests.py b/tests/regressiontests/admin_filterspecs/tests.py
index 64a6ac7..e4b1bfe 100644
a
|
b
|
class FilterSpecsTests(TestCase):
|
70 | 70 | |
71 | 71 | # Make sure the last choice is None and is selected |
72 | 72 | filterspec = changelist.get_filters(request)[0][1] |
73 | | self.assertEquals(force_unicode(filterspec.title()), u'author') |
| 73 | self.assertEquals(force_unicode(filterspec.title()), u'author_verbose') |
74 | 74 | choices = list(filterspec.choices(changelist)) |
75 | 75 | self.assertEquals(choices[-1]['selected'], True) |
76 | 76 | self.assertEquals(choices[-1]['query_string'], '?author__isnull=True') |
… |
… |
class FilterSpecsTests(TestCase):
|
80 | 80 | |
81 | 81 | # Make sure the correct choice is selected |
82 | 82 | filterspec = changelist.get_filters(request)[0][1] |
83 | | self.assertEquals(force_unicode(filterspec.title()), u'author') |
| 83 | self.assertEquals(force_unicode(filterspec.title()), u'author_verbose') |
84 | 84 | choices = list(filterspec.choices(changelist)) |
85 | 85 | self.assertEquals(choices[1]['selected'], True) |
86 | 86 | self.assertEquals(choices[1]['query_string'], '?author__id__exact=1') |
… |
… |
class FilterSpecsTests(TestCase):
|
96 | 96 | |
97 | 97 | # Make sure the last choice is None and is selected |
98 | 98 | filterspec = changelist.get_filters(request)[0][2] |
99 | | self.assertEquals(force_unicode(filterspec.title()), u'user') |
| 99 | self.assertEquals(force_unicode(filterspec.title()), u'contributors_verbose') |
100 | 100 | choices = list(filterspec.choices(changelist)) |
101 | 101 | self.assertEquals(choices[-1]['selected'], True) |
102 | 102 | self.assertEquals(choices[-1]['query_string'], '?contributors__isnull=True') |
… |
… |
class FilterSpecsTests(TestCase):
|
106 | 106 | |
107 | 107 | # Make sure the correct choice is selected |
108 | 108 | filterspec = changelist.get_filters(request)[0][2] |
109 | | self.assertEquals(force_unicode(filterspec.title()), u'user') |
| 109 | self.assertEquals(force_unicode(filterspec.title()), u'contributors_verbose') |
110 | 110 | choices = list(filterspec.choices(changelist)) |
111 | 111 | self.assertEquals(choices[2]['selected'], True) |
112 | 112 | self.assertEquals(choices[2]['query_string'], '?contributors__id__exact=2') |