From c934beea01b62ae0daa3ee09f1bad3fac835b019 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Tue, 15 Apr 2008 04:52:39 +0000 Subject: [PATCH] Fixed #6957 -- Removed a stray reference to QuerySet._select_related and added a way to copy the select_related() settings from an existing queryset. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7425 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/views/main.py | 3 +-- django/db/models/query.py | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 084a2f67cb..2b7a690a83 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -750,8 +750,7 @@ class ChangeList(object): for bit in self.query.split(): or_queries = [models.Q(**{construct_search(field_name): bit}) for field_name in self.lookup_opts.admin.search_fields] other_qs = QuerySet(self.model) - if qs._select_related: - other_qs = other_qs.select_related() + other_qs.dup_select_related(qs) other_qs = other_qs.filter(reduce(operator.or_, or_queries)) qs = qs & other_qs diff --git a/django/db/models/query.py b/django/db/models/query.py index d9c2f8144b..9f9d5a6ce3 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -402,6 +402,13 @@ class _QuerySet(object): obj.query.max_depth = depth return obj + def dup_select_related(self, other): + """ + Copies the related selection status from the queryset 'other' to the + current queryset. + """ + self.query.select_related = other.query.select_related + def order_by(self, *field_names): """Returns a new QuerySet instance with the ordering changed.""" assert self.query.can_filter(), \