Ticket #6933: django-6933-1.diff
File django-6933-1.diff, 1.9 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/views/main.py
11 11 from django.db.models.query import QuerySet 12 12 from django.http import Http404, HttpResponse, HttpResponseRedirect 13 13 from django.utils.html import escape 14 from django.utils.text import capfirst, get_text_list 14 from django.utils.text import capfirst, get_text_list, smart_split 15 15 from django.utils.encoding import force_unicode, smart_str 16 16 from django.utils.translation import ugettext as _ 17 17 from django.utils.safestring import mark_safe … … 732 732 return "%s__icontains" % field_name 733 733 734 734 if self.lookup_opts.admin.search_fields and self.query: 735 for bit in self.query.split(): 735 for bit in smart_split(self.query): 736 bit = bit.strip("\'\"") 736 737 or_queries = [models.Q(**{construct_search(field_name): bit}) for field_name in self.lookup_opts.admin.search_fields] 737 738 other_qs = QuerySet(self.model) 738 739 other_qs.dup_select_related(qs) -
docs/model-api.txt
1626 1626 WHERE (first_name ILIKE '%john%' OR last_name ILIKE '%john%') 1627 1627 AND (first_name ILIKE '%lennon%' OR last_name ILIKE '%lennon%') 1628 1628 1629 .. admonition:: Note 1630 1631 To search for phrase with a space use quotes. Supports double and 1632 single quotes, and supports escaping quotes with backslashes. 1633 ``"Foo bar" boo`` searches for ``foo bar`` and ``boo`` while 1634 ``foo bar boo`` searches for ``foo`` and ``bar`` and ``foo``. 1635 1629 1636 For faster and/or more restrictive searches, prefix the field name 1630 1637 with an operator: 1631 1638