Code

Ticket #8806: model_admin_manager.patch

File model_admin_manager.patch, 1.0 KB (added by alon, 6 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index f01edbc..e192d9d 100644
    a b class ModelAdmin(BaseModelAdmin): 
    166166    ordering = None 
    167167    inlines = [] 
    168168 
     169    manager = None 
     170 
    169171    # Custom templates (designed to be over-ridden in subclasses) 
    170172    change_form_template = None 
    171173    change_list_template = None 
    class ModelAdmin(BaseModelAdmin): 
    239241        Returns a QuerySet of all model instances that can be edited by the 
    240242        admin site. This is used by changelist_view. 
    241243        """ 
    242         qs = self.model._default_manager.get_query_set() 
     244        if self.manager is None: 
     245            qs = self.model._default_manager.get_query_set() 
     246        else: 
     247            qs = self.manager.get_query_set() 
    243248        # TODO: this should be handled by some parameter to the ChangeList. 
    244249        ordering = self.ordering or () # otherwise we might try to *None, which is bad ;) 
    245250        if ordering: