Code

Ticket #10742: 10742_three-valued-list_select_related.diff

File 10742_three-valued-list_select_related.diff, 1.6 KB (added by mrts, 5 years ago)
Line 
1Index: django/contrib/admin/validation.py
2===================================================================
3--- django/contrib/admin/validation.py  (revision 10405)
4+++ django/contrib/admin/validation.py  (working copy)
5@@ -135,15 +135,20 @@
6                     "callable nor a method on %s" % (cls.__name__, idx, cls.__name__))
7 
8 
9-    # list_select_related = False
10     # save_as = False
11     # save_on_top = False
12-    for attr in ('list_select_related', 'save_as', 'save_on_top'):
13+    for attr in ('save_as', 'save_on_top'):
14         if not isinstance(getattr(cls, attr), bool):
15             raise ImproperlyConfigured("'%s.%s' should be a boolean."
16                     % (cls.__name__, attr))
17 
18+    # list_select_related = True, False, None
19+    if (not isinstance(cls.list_select_related, bool) and
20+            cls.list_select_related is not None):
21+        raise ImproperlyConfigured("'%s.list_select_related' should "
22+                "be a boolean or None." % cls.__name__)
23 
24+
25     # inlines = []
26     if hasattr(cls, 'inlines'):
27         check_isseq(cls, 'inlines', cls.inlines)
28Index: django/contrib/admin/views/main.py
29===================================================================
30--- django/contrib/admin/views/main.py  (revision 10405)
31+++ django/contrib/admin/views/main.py  (working copy)
32@@ -200,6 +200,8 @@
33         # with a relationship.
34         if self.list_select_related:
35             qs = qs.select_related()
36+        elif self.list_select_related is None:
37+            pass
38         else:
39             for field_name in self.list_display:
40                 try: