From 50dd07db4aa1fcc588552c97c62e860b8ee4cd78 Mon Sep 17 00:00:00 2001 From: Guiomar Valderrama Date: Sun, 28 Feb 2021 16:05:21 +0100 Subject: [PATCH 1/2] add search with unaccent in search filter --- rest_framework/filters.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rest_framework/filters.py b/rest_framework/filters.py index 3665775195..017fbc7dd0 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -45,6 +45,7 @@ class SearchFilter(BaseFilterBackend): '=': 'iexact', '@': 'search', '$': 'iregex', + '&': 'unaccent', } search_title = _('Search') search_description = _('A search term.') From dff5563da5d42e0ab9b9d9e49d710b4c205e4a17 Mon Sep 17 00:00:00 2001 From: Guiomar Valderrama Date: Sun, 28 Feb 2021 16:06:03 +0100 Subject: [PATCH 2/2] add how to use unaccent in filter search in docs --- docs/api-guide/filtering.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/api-guide/filtering.md b/docs/api-guide/filtering.md index d305ede6ba..3e004ed8b6 100644 --- a/docs/api-guide/filtering.md +++ b/docs/api-guide/filtering.md @@ -226,6 +226,7 @@ The search behavior may be restricted by prepending various characters to the `s * '=' Exact matches. * '@' Full-text search. (Currently only supported Django's [PostgreSQL backend](https://docs.djangoproject.com/en/dev/ref/contrib/postgres/search/).) * '$' Regex search. +* '&' Accent-insensitive search. (Currently only supported Django's [PostgreSQL backend](https://docs.djangoproject.com/en/dev/ref/contrib/postgres/lookups/#unaccent).) For example: