Code

Ticket #8213: select_related_list.patch

File select_related_list.patch, 1.4 KB (added by Reflejo, 6 years ago)

patch against #8290

  • django/contrib/admin/validation.py

     
    9393                continue 
    9494            _check_field_existsw('ordering[%d]' % idx, field) 
    9595 
    96     # list_select_related = False 
    9796    # save_as = False 
    9897    # save_on_top = False 
    99     for attr in ('list_select_related', 'save_as', 'save_on_top'): 
     98    for attr in ('save_as', 'save_on_top'): 
    10099        if not isinstance(getattr(cls, attr), bool): 
    101100            raise ImproperlyConfigured("`%s.%s` should be a boolean." 
    102101                    % (cls.__name__, attr)) 
  • django/contrib/admin/views/main.py

     
    185185        # Use select_related() if one of the list_display options is a field 
    186186        # with a relationship. 
    187187        if self.list_select_related: 
    188             qs = qs.select_related() 
     188            if isinstance(self.list_select_related, (list, tuple)): 
     189                related_tables = self.list_select_related 
     190            else: 
     191                related_tables = [] 
     192            qs = qs.select_related(*related_tables) 
    189193        else: 
    190194            for field_name in self.list_display: 
    191195                try: