summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorAlix <alix@spacefoot.com>2020-05-26 17:53:18 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-18 20:17:20 +0200
commit26a413507abb38f7eee4cf62f2ee9727fdc7bf8d (patch)
treecda26a7382c5158bbad510ccc7b80612f921d0ad /docs/ref
parent8a902b7ee622ada258d15fb122092c1f02b82698 (diff)
Fixed #6933 -- Added support for searching against quoted phrases in ModelAdmin.search_fields.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/admin/index.txt16
1 files changed, 12 insertions, 4 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index b85711d510..df956c6bf3 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -1309,14 +1309,18 @@ subclass::
WHERE (first_name ILIKE '%john%' OR last_name ILIKE '%john%')
AND (first_name ILIKE '%lennon%' OR last_name ILIKE '%lennon%')
+ The search query can contain quoted phrases with spaces. For example, if a
+ user searches for ``"john winston"`` or ``'john winston'``, Django will do
+ the equivalent of this SQL ``WHERE`` clause:
+
+ .. code-block:: sql
+
+ WHERE (first_name ILIKE '%john winston%' OR last_name ILIKE '%john winston%')
+
If you don't want to use ``icontains`` as the lookup, you can use any
lookup by appending it the field. For example, you could use :lookup:`exact`
by setting ``search_fields`` to ``['first_name__exact']``.
- Beware that because query terms are split and ANDed as described earlier,
- searching with :lookup:`exact` only works with a single search word since
- two or more words can't all be an exact match unless all words are the same.
-
Some (older) shortcuts for specifying a field lookup are also available.
You can prefix a field in ``search_fields`` with the following characters
and it's equivalent to adding ``__<lookup>`` to the field:
@@ -1334,6 +1338,10 @@ subclass::
:meth:`ModelAdmin.get_search_results` to provide additional or alternate
search behavior.
+ .. versionchanged:: 3.2
+
+ Support for searching against quoted phrases with spaces was added.
+
.. attribute:: ModelAdmin.show_full_result_count
Set ``show_full_result_count`` to control whether the full count of objects