From 4ade8386ebfeb7a781dc2b62542c1cf5f8b9ddaf Mon Sep 17 00:00:00 2001 From: Tom Carrick Date: Tue, 4 Apr 2023 15:11:11 +0100 Subject: Fixed #10743 -- Allowed lookups for related fields in ModelAdmin.list_display. Co-authored-by: Alex Garcia Co-authored-by: Natalia <124304+nessita@users.noreply.github.com> Co-authored-by: Nina Menezes --- tests/modeladmin/test_checks.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'tests/modeladmin') diff --git a/tests/modeladmin/test_checks.py b/tests/modeladmin/test_checks.py index 73777f05ab..f767a6c92b 100644 --- a/tests/modeladmin/test_checks.py +++ b/tests/modeladmin/test_checks.py @@ -69,7 +69,7 @@ class RawIdCheckTests(CheckTestCase): def test_missing_field(self): class TestModelAdmin(ModelAdmin): - raw_id_fields = ("non_existent_field",) + raw_id_fields = ["non_existent_field"] self.assertIsInvalid( TestModelAdmin, @@ -602,8 +602,21 @@ class ListDisplayTests(CheckTestCase): TestModelAdmin, ValidationTestModel, "The value of 'list_display[0]' refers to 'non_existent_field', " - "which is not a callable, an attribute of 'TestModelAdmin', " - "or an attribute or method on 'modeladmin.ValidationTestModel'.", + "which is not a callable or attribute of 'TestModelAdmin', " + "or an attribute, method, or field on 'modeladmin.ValidationTestModel'.", + "admin.E108", + ) + + def test_missing_related_field(self): + class TestModelAdmin(ModelAdmin): + list_display = ("band__non_existent_field",) + + self.assertIsInvalid( + TestModelAdmin, + ValidationTestModel, + "The value of 'list_display[0]' refers to 'band__non_existent_field', " + "which is not a callable or attribute of 'TestModelAdmin', " + "or an attribute, method, or field on 'modeladmin.ValidationTestModel'.", "admin.E108", ) -- cgit v1.3