diff options
| author | Tom Carrick <tom@carrick.eu> | 2023-04-04 15:11:11 +0100 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2024-02-05 21:42:04 -0300 |
| commit | 4ade8386ebfeb7a781dc2b62542c1cf5f8b9ddaf (patch) | |
| tree | 97263c4f927ad797883bba77db95c6dee6041df4 /tests/admin_checks/tests.py | |
| parent | 3580b47ed31ec85ae89b13618f36bb463e97acc8 (diff) | |
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>
Diffstat (limited to 'tests/admin_checks/tests.py')
| -rw-r--r-- | tests/admin_checks/tests.py | 23 |
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) |
