Ticket #7113: changelist_custom_qs.diff

File changelist_custom_qs.diff, 1.1 KB (added by jbronn, 17 years ago)

Allows for custom querysets in the admin changelist.

  • django/contrib/admin/views/main.py

     
    121121        self.opts = model._meta
    122122        self.lookup_opts = self.opts
    123123        self.root_query_set = model_admin.queryset(request)
     124        self.root_query_set_class = type(self.root_query_set)
    124125        self.list_display = list_display
    125126        self.list_display_links = list_display_links
    126127        self.list_filter = list_filter
     
    300301        if self.search_fields and self.query:
    301302            for bit in self.query.split():
    302303                or_queries = [models.Q(**{construct_search(field_name): bit}) for field_name in self.search_fields]
    303                 other_qs = QuerySet(self.model)
     304                other_qs = self.root_query_set_class(self.model)
    304305                other_qs.dup_select_related(qs)
    305306                other_qs = other_qs.filter(reduce(operator.or_, or_queries))
    306307                qs = qs & other_qs
Back to Top