diff -r 248bfcafb5d1 django/contrib/admin/views/main.py
a
|
b
|
|
241 | 241 | return "%s__icontains" % field_name |
242 | 242 | |
243 | 243 | if self.search_fields and self.query: |
244 | | for bit in self.query.split(): |
245 | | or_queries = [models.Q(**{construct_search(str(field_name)): bit}) for field_name in self.search_fields] |
246 | | qs = qs.filter(reduce(operator.or_, or_queries)) |
| 244 | search_queries = [models.Q(**{construct_search(field_name): self.query}) |
| 245 | for field_name in map(str, self.search_fields) |
| 246 | if field_name.startswith('=')] |
| 247 | if len(self.search_fields) > 1 or not search_queries: |
| 248 | and_queries = [] |
| 249 | for bit in self.query.split(): |
| 250 | or_queries = [models.Q(**{construct_search(field_name): bit}) |
| 251 | for field_name in map(str, self.search_fields)] |
| 252 | and_queries.append(reduce(operator.or_, or_queries)) |
| 253 | if and_queries: |
| 254 | search_queries.append(reduce(operator.and_, and_queries)) |
| 255 | if search_queries: |
| 256 | qs = qs.filter(reduce(operator.or_, search_queries)) |
247 | 257 | for field_name in self.search_fields: |
248 | 258 | if '__' in field_name: |
249 | 259 | qs = qs.distinct() |