Ticket #10348: 10348_with-none-and-explicit-select-related.diff
File 10348_with-none-and-explicit-select-related.diff, 2.1 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/validation.py
127 127 continue 128 128 get_field(cls, model, opts, 'ordering[%d]' % idx, field) 129 129 130 # list_select_related = False131 130 # save_as = False 132 131 # save_on_top = False 133 for attr in (' list_select_related', 'save_as', 'save_on_top'):132 for attr in ('save_as', 'save_on_top'): 134 133 if not isinstance(getattr(cls, attr), bool): 135 134 raise ImproperlyConfigured("'%s.%s' should be a boolean." 136 135 % (cls.__name__, attr)) 137 136 137 # list_select_related = True, False, None 138 if (not isinstance(cls.list_select_related, bool) and 139 cls.list_select_related is not None): 140 raise ImproperlyConfigured("'%s.list_select_related' should " 141 "be a boolean or None." % cls.__name__) 138 142 143 139 144 # inlines = [] 140 145 if hasattr(cls, 'inlines'): 141 146 check_isseq(cls, 'inlines', cls.inlines) -
django/contrib/admin/views/main.py
200 200 # with a relationship. 201 201 if self.list_select_related: 202 202 qs = qs.select_related() 203 elif self.list_select_related is None: 204 pass 203 205 else: 206 select_related = [] 204 207 for field_name in self.list_display: 205 208 try: 206 209 f = self.lookup_opts.get_field(field_name) … … 208 211 pass 209 212 else: 210 213 if isinstance(f.rel, models.ManyToOneRel): 211 qs = qs.select_related() 212 break 214 select_related.append(field_name) 215 if select_related: 216 qs = qs.select_related(*select_related) 213 217 214 218 # Set ordering. 215 219 if self.order_field: