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__startswith=self.q) return qs