diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/admin_views/admin.py | 6 | ||||
| -rw-r--r-- | tests/admin_views/tests.py | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index 158f42ea67..b4e67f0a23 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -169,7 +169,11 @@ class ThingAdmin(admin.ModelAdmin): class InquisitionAdmin(admin.ModelAdmin): - list_display = ('leader', 'country', 'expected') + list_display = ('leader', 'country', 'expected', 'sketch') + + def sketch(self, obj): + # A method with the same name as a reverse accessor. + return 'list-display-sketch' class SketchAdmin(admin.ModelAdmin): diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index b5dff27e6b..dd96715605 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -4230,6 +4230,16 @@ class RawIdFieldsTest(TestCase): self.assertNotContains(response2, "Kilbraken") self.assertContains(response2, "Palin") + def test_list_display_method_same_name_as_reverse_accessor(self): + """ + Should be able to use a ModelAdmin method in list_display that has the + same name as a reverse model field ("sketch" in this case). + """ + actor = Actor.objects.create(name="Palin", age=27) + Inquisition.objects.create(expected=True, leader=actor, country="England") + response = self.client.get(reverse('admin:admin_views_inquisition_changelist')) + self.assertContains(response, 'list-display-sketch') + @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), ROOT_URLCONF="admin_views.urls") |
