Code

Ticket #6933: django-6933-0.3.diff

File django-6933-0.3.diff, 892 bytes (added by diafour, 6 years ago)
Line 
1Index: main.py
2===================================================================
3--- main.py     (revision 7894)
4+++ main.py     (working copy)
5@@ -731,8 +731,15 @@
6             else:
7                 return "%s__icontains" % field_name
8 
9+        def query_split(query):
10+            first_bits = query.split('"')
11+            result_bits = first_bits[1::2]
12+                for bit in first_bits[0::2]:
13+                result_bits.extend( bit.split() )
14+            return result_bits
15+
16         if self.lookup_opts.admin.search_fields and self.query:           
17-            for bit in self.query.split():
18+            for bit in query_split(self.query):
19                 or_queries = [models.Q(**{construct_search(field_name): bit}) for field_name in self.lookup_opts.admin.search_fields]
20                 other_qs = QuerySet(self.model)
21                 other_qs.dup_select_related(qs)