Autocomplete: Podpora více částí v autocomplete řešitelů
This commit is contained in:
parent
3f3f6ebb0f
commit
93966ca2a9
1 changed files with 8 additions and 4 deletions
|
@ -26,11 +26,15 @@ class ResitelAutocomplete(LoginRequiredAjaxMixin,autocomplete.Select2QuerySetVie
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
qs = m.Resitel.objects.all()
|
qs = m.Resitel.objects.all()
|
||||||
if self.q:
|
if self.q:
|
||||||
qs = qs.filter(
|
parts = self.q.split()
|
||||||
Q(osoba__jmeno__istartswith=self.q)|
|
query = Q()
|
||||||
Q(osoba__prijmeni__istartswith=self.q)|
|
for part in parts:
|
||||||
Q(osoba__prezdivka__istartswith=self.q)
|
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
|
return qs
|
||||||
|
|
||||||
class OdevzdatelnyProblemAutocomplete(autocomplete.Select2QuerySetView):
|
class OdevzdatelnyProblemAutocomplete(autocomplete.Select2QuerySetView):
|
||||||
|
|
Loading…
Reference in a new issue