1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

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

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