mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-18 12:12:19 +03:00
Improve search documentation
This commit is contained in:
parent
a7bafb7392
commit
67cd9c2259
|
@ -218,14 +218,18 @@ For [JSONField][JSONField] and [HStoreField][HStoreField] fields you can filter
|
||||||
|
|
||||||
search_fields = ['data__breed', 'data__owner__other_pets__0__name']
|
search_fields = ['data__breed', 'data__owner__other_pets__0__name']
|
||||||
|
|
||||||
By default, searches will use case-insensitive partial matches. The search parameter may contain multiple search terms, which should be whitespace separated. If multiple search terms are used then objects will be returned in the list only if all the provided terms are matched.
|
By default, searches will use case-insensitive partial matches. The search parameter may contain multiple search terms, which should be whitespace and/or comma separated . If multiple search terms are used then objects will be returned in the list only if all the provided terms are matched. Searches may contain _quoted phrases_ with spaces, each phrase is considered as a single search term.
|
||||||
|
|
||||||
The search behavior may be restricted by prepending various characters to the `search_fields`.
|
|
||||||
|
|
||||||
* '^' Starts-with search.
|
The search behavior may be specified by prefixing field names in `search_fields` with one of the following characters (which is equivalent to adding `__<lookup>` to the field):
|
||||||
* '=' Exact matches.
|
|
||||||
* '@' Full-text search. (Currently only supported Django's [PostgreSQL backend][postgres-search].)
|
| Prefix | Lookup | |
|
||||||
* '$' Regex search.
|
| ------ | --------------| ------------------ |
|
||||||
|
| `^` | `istartswith` | Starts-with search.|
|
||||||
|
| `=` | `iexact` | Exact matches. |
|
||||||
|
| `$` | `iregex` | Regex search. |
|
||||||
|
| `@` | `search` | Full-text search (Currently only supported Django's [PostgreSQL backend][postgres-search]). |
|
||||||
|
| None | `icontains` | Contains search (Default). |
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user