From 4b2b4bf0ac2707dc9c4d51cabfa72168eaea95fe Mon Sep 17 00:00:00 2001 From: huwaiza tahir Date: Wed, 18 Mar 2026 12:40:04 +0500 Subject: Fixed #36926 -- Made admin use boolean icons for related BooleanFields in list_display. When using related field lookups like 'parent__is_active' in list_display, the admin now correctly detects if the final field is a BooleanField and displays boolean icons instead of 'True'/'False' text. Modified lookup_field() in django/contrib/admin/utils.py to retrieve the final field from the path when traversing relations using LOOKUP_SEP (__), allowing display_for_field() to properly handle BooleanFields. --- django/contrib/admin/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'django') diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py index e604a27750..3d5b023dea 100644 --- a/django/contrib/admin/utils.py +++ b/django/contrib/admin/utils.py @@ -294,6 +294,7 @@ def lookup_field(name, obj, model_admin=None): except (FieldDoesNotExist, FieldIsAForeignKeyColumnName): # For non-regular field values, the value is either a method, # property, related field, or returned via a callable. + f = None if callable(name): attr = name value = attr(obj) @@ -312,10 +313,12 @@ def lookup_field(name, obj, model_admin=None): attr = getattr(attr, part, sentinel) if attr is sentinel: return None, None, None + # The final field is needed for displaying boolean icons. + if LOOKUP_SEP in name: + f = get_fields_from_path(opts.model, name)[-1] value = attr if hasattr(model_admin, "model") and hasattr(model_admin.model, name): attr = getattr(model_admin.model, name) - f = None else: attr = None value = getattr(obj, name) -- cgit v1.3