201 | | qs = qs.select_related() |
202 | | else: |
203 | | for field_name in self.list_display: |
204 | | try: |
205 | | f = self.lookup_opts.get_field(field_name) |
206 | | except models.FieldDoesNotExist: |
207 | | pass |
208 | | else: |
209 | | if isinstance(f.rel, models.ManyToOneRel): |
210 | | qs = qs.select_related() |
211 | | break |
| 201 | select_related = getattr(self.model_admin, 'select_related', None) |
| 202 | if select_related == None: |
| 203 | select_related = [] |
| 204 | for field_name in self.list_display: |
| 205 | try: |
| 206 | f = self.lookup_opts.get_field(field_name) |
| 207 | except models.FieldDoesNotExist: |
| 208 | pass |
| 209 | else: |
| 210 | if isinstance(f.rel, models.ManyToOneRel): |
| 211 | select_related.append(field_name) |
| 212 | if select_related: |
| 213 | qs = qs.select_related(*select_related) |