From 93966ca2a901f4cd46ed1b02ab525cb59e65661b Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Mon, 15 Nov 2021 21:04:27 +0100 Subject: [PATCH] =?UTF-8?q?Autocomplete:=20Podpora=20v=C3=ADce=20=C4=8D?= =?UTF-8?q?=C3=A1st=C3=AD=20v=20autocomplete=20=C5=99e=C5=A1itel=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/views/autocomplete.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/views/autocomplete.py b/api/views/autocomplete.py index a97fbbab..98087cc8 100644 --- a/api/views/autocomplete.py +++ b/api/views/autocomplete.py @@ -26,11 +26,15 @@ class ResitelAutocomplete(LoginRequiredAjaxMixin,autocomplete.Select2QuerySetVie def get_queryset(self): qs = m.Resitel.objects.all() if self.q: - qs = qs.filter( - Q(osoba__jmeno__istartswith=self.q)| - Q(osoba__prijmeni__istartswith=self.q)| - Q(osoba__prezdivka__istartswith=self.q) + parts = self.q.split() + query = Q() + for part in parts: + query &= ( + Q(osoba__jmeno__istartswith=self.q)| + Q(osoba__prijmeni__istartswith=self.q)| + Q(osoba__prezdivka__istartswith=self.q) ) + qs = qs.filter(query) return qs class OdevzdatelnyProblemAutocomplete(autocomplete.Select2QuerySetView):