From 184c7a10e017254da4800a67d6b8f7757180c327 Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Tue, 26 Mar 2024 23:38:32 +0100 Subject: [PATCH] fix #120: Add support for UTF-8 characters in IncompleteSelectMixin --- formset/widgets.py | 2 ++ testapp/migrations/0001_initial.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/formset/widgets.py b/formset/widgets.py index e32bbc90..8b0998ef 100644 --- a/formset/widgets.py +++ b/formset/widgets.py @@ -12,6 +12,7 @@ from django.db.models.query_utils import Q from django.forms.models import ModelChoiceIterator, ModelChoiceIteratorValue from django.forms.widgets import DateTimeBaseInput, FileInput, Select, SelectMultiple, TextInput, Widget +from django.utils.encoding import uri_to_iri from django.utils.timezone import datetime, now from django.utils.translation import gettext_lazy as _ @@ -108,6 +109,7 @@ def build_filter_query(self, filters): raise ImproperlyConfigured(f"Invalid attribute 'filter_by' in {self.__class__}.") def build_search_query(self, search_term): + search_term = uri_to_iri(search_term) try: return reduce(or_, (Q(**{sl: search_term}) for sl in self.search_lookup)) except TypeError: diff --git a/testapp/migrations/0001_initial.py b/testapp/migrations/0001_initial.py index 35f4d684..50e9f64b 100644 --- a/testapp/migrations/0001_initial.py +++ b/testapp/migrations/0001_initial.py @@ -14,6 +14,15 @@ def initialize_opinions(apps, schema_editor): for counter in range(1, 3000): label = f"Opinion {counter:04}" OpinionModel.objects.create(tenant=1, label=label) + for counter in range(1, 500): + label = f"Übung {counter:04}" + OpinionModel.objects.create(tenant=1, label=label) + for counter in range(1, 500): + label = f"Оптион {counter:04}" + OpinionModel.objects.create(tenant=1, label=label) + for counter in range(1, 500): + label = f"επιλογή {counter:04}" + OpinionModel.objects.create(tenant=1, label=label) def initialize_counties(apps, schema_editor):