You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wish/wishlist/views_autocomplete.py

15 lines
365 B
Python

from dal import autocomplete
from wishlist.models import WishList
class WishListAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
if not self.request.user.is_authenticated:
return WishList.objects.none()
qs = WishList.objects.all().filter(owner=self.request.user)
if self.q:
qs = qs.filter(name__icontains=self.q)
return qs