Django

Code

Changeset 4335

Show
Ignore:
Timestamp:
01/15/07 18:51:22 (2 years ago)
Author:
adrian
Message:

newforms-admin: Moved list_select_related from AdminOptions? to ModelAdmin?.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/newforms-admin/django/contrib/admin/options.py

    r4334 r4335  
    3737    list_display_links = () 
    3838    list_filter = () 
     39    list_select_related = False 
    3940    search_fields = () 
    4041    date_hierarchy = None 
     
    276277        try: 
    277278            cl = ChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter, 
    278                 self.date_hierarchy, self.search_fields
     279                self.date_hierarchy, self.search_fields, self.list_select_related
    279280        except IncorrectLookupParameters: 
    280281            # Wacky lookup parameters were given, so redirect to the main 
  • django/branches/newforms-admin/django/contrib/admin/views/main.py

    r4334 r4335  
    293293 
    294294class ChangeList(object): 
    295     def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields): 
     295    def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related): 
    296296        self.model = model 
    297297        self.opts = model._meta 
     
    303303        self.date_hierarchy = date_hierarchy 
    304304        self.search_fields = search_fields 
     305        self.list_select_related = list_select_related 
    305306 
    306307        # Get search parameters from the query string. 
     
    433434        # Use select_related() if one of the list_display options is a field 
    434435        # with a relationship. 
    435         if self.lookup_opts.admin.list_select_related: 
     436        if self.list_select_related: 
    436437            qs = qs.select_related() 
    437438        else: 
  • django/branches/newforms-admin/django/db/models/base.py

    r4334 r4335  
    138138            cls._meta.ModelAdmin = type('ModelAdmin', (value, ModelAdmin), {}) 
    139139            # This AdminOptions stuff is legacy and will eventually be removed. 
    140             value = AdminOptions(**dict([(k, v) for k, v in value.__dict__.items() if not k.startswith('_') and k not in ('list_display', 'list_display_links', 'list_filter', 'date_hierarchy', 'save_as', 'search_fields')])) 
     140            value = AdminOptions(**dict([(k, v) for k, v in value.__dict__.items() if not k.startswith('_') and k not in ('list_display', 'list_display_links', 'list_filter', 'date_hierarchy', 'save_as', 'search_fields', 'list_select_related')])) 
    141141            value.contribute_to_class(cls, name) 
    142142        elif hasattr(value, 'contribute_to_class'): 
  • django/branches/newforms-admin/django/db/models/options.py

    r4334 r4335  
    202202    def __init__(self, fields=None, js=None, 
    203203        ordering=None, 
    204         save_on_top=False, list_select_related=False, manager=None, list_per_page=100): 
     204        save_on_top=False, manager=None, list_per_page=100): 
    205205        self.fields = fields 
    206206        self.js = js or [] 
    207207        self.ordering = ordering 
    208208        self.save_on_top = save_on_top 
    209         self.list_select_related = list_select_related 
    210209        self.list_per_page = list_per_page 
    211210        self.manager = manager or Manager()