diff options
Diffstat (limited to 'tests/admin_changelist/tests.py')
| -rw-r--r-- | tests/admin_changelist/tests.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index f051849449..ef0f8a0570 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -1768,6 +1768,35 @@ class ChangeListTests(TestCase): cl = m.get_changelist_instance(request) self.assertEqual(cl.get_ordering_field_columns(), {2: "asc"}) + def test_list_display_related_field_boolean_display(self): + """ + Related boolean fields (parent__is_active) display boolean icons. + """ + parent = Parent.objects.create(name="Test Parent") + child_active = Child.objects.create( + name="Active Child", parent=parent, is_active=True + ) + child_inactive = Child.objects.create( + name="Inactive Child", parent=parent, is_active=False + ) + + class GrandChildAdmin(admin.ModelAdmin): + list_display = ["name", "parent__is_active"] + + GrandChild.objects.create(name="GrandChild of Active", parent=child_active) + GrandChild.objects.create(name="GrandChild of Inactive", parent=child_inactive) + + m = GrandChildAdmin(GrandChild, custom_site) + request = self._mocked_authenticated_request("/grandchild/", self.superuser) + response = m.changelist_view(request) + + # Boolean icons are rendered using img tags with specific alt text. + self.assertContains(response, 'alt="True"') + self.assertContains(response, 'alt="False"') + # Ensure "True" and "False" text are NOT in the response. + self.assertNotContains(response, ">True<") + self.assertNotContains(response, ">False<") + class GetAdminLogTests(TestCase): def test_custom_user_pk_not_named_id(self): |
