Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

newforms-admin: Fixed #2818 -- Filtered out duplicate results when se…

…arching in

the admin across related fields. Thanks, Andy Dustman.


git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5123 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4938c8ea6db6f23ebb0883b8a092985344508b25 1 parent e8b2a86
@malcolmt malcolmt authored
Showing with 4 additions and 0 deletions.
  1. +4 −0 django/contrib/admin/views/main.py
View
4 django/contrib/admin/views/main.py
@@ -436,6 +436,10 @@ def construct_search(field_name):
other_qs = other_qs.select_related()
other_qs = other_qs.filter(reduce(operator.or_, or_queries))
qs = qs & other_qs
+ for field_name in self.search_fields:
+ if '__' in field_name:
+ qs = qs.distinct()
+ break
if self.opts.one_to_one_field:
qs = qs.complex_filter(self.opts.one_to_one_field.rel.limit_choices_to)
Please sign in to comment.
Something went wrong with that request. Please try again.