Ticket #15517: patch_modeladmin_search_fields.diff
File patch_modeladmin_search_fields.diff, 1.2 KB (added by , 14 years ago) |
---|
-
django/contrib/admin/views/main.py
254 254 return "%s__icontains" % field_name 255 255 256 256 if self.search_fields and self.query: 257 constructed_fields = [construct_search(str(field_name)) 258 for field_name in self.search_fields] 257 259 for bit in self.query.split(): 258 or_queries = [models.Q(**{construct_search(str(field_name)): bit}) for field_name in self.search_fields] 260 or_queries = [models.Q(**{field_name: bit}) 261 for field_name in constructed_fields] 259 262 qs = qs.filter(reduce(operator.or_, or_queries)) 260 263 if not use_distinct: 261 for search_field in self.search_fields:264 for search_field in constructed_fields: 262 265 field_name = search_field.split('__', 1)[0] 263 266 f = self.lookup_opts.get_field_by_name(field_name)[0] 264 267 if hasattr(f, 'rel') and isinstance(f.rel, models.ManyToManyRel):