Code

Ticket #14982: none_value.11297.1.2.4.diff

File none_value.11297.1.2.4.diff, 912 bytes (added by marcob, 3 years ago)
Line 
1diff -r d40a8d6441fe lib/django/contrib/admin/templatetags/admin_list.py
2--- a/lib/django/contrib/admin/templatetags/admin_list.py       Tue Dec 28 21:54:16 2010 +0100
3+++ b/lib/django/contrib/admin/templatetags/admin_list.py       Tue Dec 28 22:11:39 2010 +0100
4@@ -158,7 +158,11 @@
5                 if value is None:
6                     result_repr = EMPTY_CHANGELIST_VALUE
7                 if isinstance(f.rel, models.ManyToOneRel):
8-                    result_repr = escape(getattr(result, f.name))
9+                    field_val = getattr(result, f.name)
10+                    if field_val is None:
11+                        result_repr = EMPTY_CHANGELIST_VALUE
12+                    else:
13+                        result_repr = escape(field_val)
14                 else:
15                     result_repr = display_for_field(value, f)
16                 if isinstance(f, models.DateField) or isinstance(f, models.TimeField):