Ticket #6933: django-6933-0.2.diff

File django-6933-0.2.diff, 957 bytes (added by diafour, 7 years ago)
  • main.py

     
    731731            else:
    732732                return "%s__icontains" % field_name
    733733
    734         if self.lookup_opts.admin.search_fields and self.query:
    735             for bit in self.query.split():
     734        def query_split(query):
     735            first_bits = query.split('"')
     736            result_bits = first_bits[1::2]
     737                for bit in first_bits[0::2]:
     738                result_bits.extend( bit.split() )
     739            return result_bits
     740
     741        if self.lookup_opts.admin.search_fields and self.query:           
     742            for bit in query_split(self.query):
    736743                or_queries = [models.Q(**{construct_search(field_name): bit}) for field_name in self.lookup_opts.admin.search_fields]
    737744                other_qs = QuerySet(self.model)
    738745                other_qs.dup_select_related(qs)
Back to Top