From 46950aa170797e20ac99b0f31c1c1555cd4e6be4 Mon Sep 17 00:00:00 2001 From: thenav56 Date: Thu, 12 Jun 2025 10:49:24 +0545 Subject: [PATCH] feat(django): add support for unaccent search for usergroups --- django/apps/existing_database/filters.py | 2 +- mapswipe_workers/tests/integration/set_up_db.sql | 1 + postgres/initdb.sql | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/django/apps/existing_database/filters.py b/django/apps/existing_database/filters.py index 096f2f5a1..98227d94b 100644 --- a/django/apps/existing_database/filters.py +++ b/django/apps/existing_database/filters.py @@ -38,7 +38,7 @@ class UserGroupFilter: def filter_search(self, queryset): if self.search: queryset = queryset.filter( - name__icontains=self.search, + name__unaccent__icontains=self.search, ) return queryset diff --git a/mapswipe_workers/tests/integration/set_up_db.sql b/mapswipe_workers/tests/integration/set_up_db.sql index f954d3a8c..66583bb2d 100644 --- a/mapswipe_workers/tests/integration/set_up_db.sql +++ b/mapswipe_workers/tests/integration/set_up_db.sql @@ -1,5 +1,6 @@ -- noinspection SqlNoDataSourceInspectionForFile CREATE EXTENSION IF NOT EXISTS postgis; +CREATE EXTENSION IF NOT EXISTS unaccent; CREATE TABLE IF NOT EXISTS projects ( created timestamp, diff --git a/postgres/initdb.sql b/postgres/initdb.sql index f954d3a8c..66583bb2d 100644 --- a/postgres/initdb.sql +++ b/postgres/initdb.sql @@ -1,5 +1,6 @@ -- noinspection SqlNoDataSourceInspectionForFile CREATE EXTENSION IF NOT EXISTS postgis; +CREATE EXTENSION IF NOT EXISTS unaccent; CREATE TABLE IF NOT EXISTS projects ( created timestamp,