Fixed #10743 -- Allowed lookups for related fields in ModelAdmin.list_display.

Co-authored-by: Alex Garcia <me@alexoteiza.com>
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Co-authored-by: Nina Menezes <https://github.com/nmenezes0>
This commit is contained in:
Tom Carrick 2023-04-04 15:11:11 +01:00 committed by Natalia
parent 3580b47ed3
commit 4ade8386eb
13 changed files with 186 additions and 46 deletions

View file

@ -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",
)