1
0
mirror of https://github.com/TandoorRecipes/recipes.git synced 2026-01-11 00:58:32 -05:00
Files
recipes/cookbook/helper/dal.py
2018-03-31 11:29:18 +02:00

17 lines
378 B
Python

from dal import autocomplete
from cookbook.models import Keyword
class KeywordAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
if not self.request.user.is_authenticated:
return Keyword.objects.none()
qs = Keyword.objects.all()
if self.q:
qs = qs.filter(name__istartswith=self.q)
return qs