summaryrefslogtreecommitdiff
path: root/tests/admin_checks
diff options
context:
space:
mode:
Diffstat (limited to 'tests/admin_checks')
-rw-r--r--tests/admin_checks/tests.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py
index d2d1eb219e..6ca5d6d925 100644
--- a/tests/admin_checks/tests.py
+++ b/tests/admin_checks/tests.py
@@ -1009,3 +1009,26 @@ class SystemChecksTestCase(SimpleTestCase):
self.assertEqual(errors, [])
finally:
Book._meta.apps.ready = True
+
+ def test_related_field_list_display(self):
+ class SongAdmin(admin.ModelAdmin):
+ list_display = ["pk", "original_release", "album__title"]
+
+ errors = SongAdmin(Song, AdminSite()).check()
+ self.assertEqual(errors, [])
+
+ def test_related_field_list_display_wrong_field(self):
+ class SongAdmin(admin.ModelAdmin):
+ list_display = ["pk", "original_release", "album__hello"]
+
+ errors = SongAdmin(Song, AdminSite()).check()
+ expected = [
+ checks.Error(
+ "The value of 'list_display[2]' refers to 'album__hello', which is not "
+ "a callable or attribute of 'SongAdmin', or an attribute, method, or "
+ "field on 'admin_checks.Song'.",
+ obj=SongAdmin,
+ id="admin.E108",
+ )
+ ]
+ self.assertEqual(errors, expected)