Ticket #16063: django_1_2_5_admin_search_m2m_prevent_multiple_joining.diff

File django_1_2_5_admin_search_m2m_prevent_multiple_joining.diff, 943 bytes (added by Evgeny Sizikov, 13 years ago)

patch has been made from Mercurial repository

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

    diff -r 9f23205f00f4 django/contrib/admin/views/main.py
    a b  
    239239                return "%s__icontains" % field_name
    240240
    241241        if self.search_fields and self.query:
    242             for bit in self.query.split():
    243                 or_queries = [models.Q(**{construct_search(str(field_name)): bit}) for field_name in self.search_fields]
    244                 qs = qs.filter(reduce(operator.or_, or_queries))
     242            qs = qs.filter(*[reduce(operator.or_, [models.Q(**{construct_search(str(field_name)): bit})
     243                                                   for field_name in self.search_fields])
     244                             for bit in self.query.split()])
    245245            for field_name in self.search_fields:
    246246                if '__' in field_name:
    247247                    qs = qs.distinct()
Back to Top