summaryrefslogtreecommitdiff
path: root/tests/modeladmin
diff options
context:
space:
mode:
authorBakdolot <80908236+Bakdolot@users.noreply.github.com>2023-04-24 17:14:35 +0600
committerGitHub <noreply@github.com>2023-04-24 08:14:35 -0300
commitc813fb327cb1b09542be89c5ceed367826236bc2 (patch)
tree94f90414368cc6f962fcfb3f7035a1915a92c357 /tests/modeladmin
parent83c9765f45e4622e4a5af3adcd92263a28b13624 (diff)
downloaddjango-c813fb327cb1b09542be89c5ceed367826236bc2.tar.gz
Fixed #34481 -- Added system check for reverse related fields in ModelAdmin.list_display.
Diffstat (limited to 'tests/modeladmin')
-rw-r--r--tests/modeladmin/test_checks.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/modeladmin/test_checks.py b/tests/modeladmin/test_checks.py
index e4ad0636a6..85f2eda69e 100644
--- a/tests/modeladmin/test_checks.py
+++ b/tests/modeladmin/test_checks.py
@@ -537,7 +537,20 @@ class ListDisplayTests(CheckTestCase):
self.assertIsInvalid(
TestModelAdmin,
ValidationTestModel,
- "The value of 'list_display[0]' must not be a ManyToManyField.",
+ "The value of 'list_display[0]' must not be a many-to-many field or a "
+ "reverse foreign key.",
+ "admin.E109",
+ )
+
+ def test_invalid_reverse_related_field(self):
+ class TestModelAdmin(ModelAdmin):
+ list_display = ["song_set"]
+
+ self.assertIsInvalid(
+ TestModelAdmin,
+ Band,
+ "The value of 'list_display[0]' must not be a many-to-many field or a "
+ "reverse foreign key.",
"admin.E109",
)