Permalink
Browse files

Fixed #2520 -- Fixed a problem with invalid SQL being generated by admin

interface in certain circumstances. Patch from favo@exoweb.net.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3794 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent f88d582 commit 96bc9ec79d12420a765ba210a9d8313c05b13d39 @malcolmt malcolmt committed Sep 22, 2006
Showing with 3 additions and 0 deletions.
  1. +1 −0 AUTHORS
  2. +2 −0 django/contrib/admin/views/main.py
View
1 AUTHORS
@@ -72,6 +72,7 @@ answer newbie questions, and generally made Django that much better:
Jeremy Dunck <http://dunck.us/>
Andy Dustman <farcepest@gmail.com>
Clint Ecker
+ favo@exoweb.net
gandalf@owca.info
Baishampayan Ghose
martin.glueck@gmail.com
View
2 django/contrib/admin/views/main.py
@@ -727,6 +727,8 @@ def construct_search(field_name):
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 = other_qs.filter(reduce(operator.or_, or_queries))
qs = qs & other_qs

0 comments on commit 96bc9ec

Please sign in to comment.