Skip to content

Commit deb6657

Browse files
committed
Add unaccent to SearchFilter
1 parent 65aa4b8 commit deb6657

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

docs/api-guide/filtering.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ The search behavior may be specified by prefixing field names in `search_fields`
230230
| `$` | `iregex` | Regex search. |
231231
| `@` | `search` | Full-text search (Currently only supported Django's [PostgreSQL backend][postgres-search]). |
232232
| None | `icontains` | Contains search (Default). |
233+
| `&` | `unaccent` | Accent-insensitive search. (Currently only supported Django's [PostgreSQL backend][postgres-lookups]). |
233234

234235
For example:
235236

@@ -370,3 +371,4 @@ The [djangorestframework-word-filter][django-rest-framework-word-search-filter]
370371
[HStoreField]: https://docs.djangoproject.com/en/stable/ref/contrib/postgres/fields/#hstorefield
371372
[JSONField]: https://docs.djangoproject.com/en/stable/ref/models/fields/#django.db.models.JSONField
372373
[postgres-search]: https://docs.djangoproject.com/en/stable/ref/contrib/postgres/search/
374+
[postgres-lookups]: https://docs.djangoproject.com/en/stable/ref/contrib/postgres/lookups/#unaccent

rest_framework/filters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class SearchFilter(BaseFilterBackend):
5858
'=': 'iexact',
5959
'@': 'search',
6060
'$': 'iregex',
61+
'&': 'unaccent',
6162
}
6263
search_title = _('Search')
6364
search_description = _('A search term.')

0 commit comments

Comments
 (0)