def get_queryset(self): querysets = [ Resource.objects.all(), ConceptEntity.objects.all(), ] qs = QuerySetSequence(*querysets) if self.q: qs = qs.filter(name__icontains=self.q) # In addition to filtering existing Entities, we should also # consider Concepts provided by registered authority services. if len(self.q) > 3: # To avoid frivolous authority calls, we only # consider Concepts once the user has entered # four characters. extra_choices = self._suggest_concept(self.q) if not self.request.user.is_authenticated(): qs = qs.filter(private=False) field_id = self.request.GET.get('in_range_of', None) if field_id: qs = qs.filter(entity_type__in_range_of__in=[field_id]) qs = self.mixup_querysets(qs) return qs
def get_queryset(self): self.q = self.request.GET.get('term', None) template_cats = VideoCat.objects.all() tags = Tag.objects.all() if not self.q: qs = QuerySetSequence().none() else: template_cats = template_cats.filter(name__icontains=self.q) tags = tags.filter(name__icontains=self.q) # # Get Haystack search results and convert to pks for local # content = SearchQuerySet().filter(content=AutoQuery(self.q)) content_pks = [i.pk for i in content] content = Vid.objects.filter(pk__in=content_pks) # Aggregate querysets qs = QuerySetSequence(content, template_cats, tags) if self.q: # This would apply the filter on all the querysets qs = qs.filter(name__icontains=self.q) # This will limit each queryset so that they show an equal number # of results. qs = self.mixup_querysets(qs) return qs
def get_queryset(self): cards = Card.objects.all() if self.q: cards = cards.filter(name__icontains=self.q) # Aggregate querysets qs = QuerySetSequence(cards) if self.q: # This would apply the filter on all the querysets qs = qs.filter(name__icontains=self.q) # This will limit each queryset so that they show an equal number # of results. qs = self.mixup_querysets(qs) return qs
def get_queryset(self): self.q = self.request.GET.get('term', None) template_cats = VideoCat.objects.all() tags = Tag.objects.all() if self.q: template_cats = template_cats.filter(name__icontains=self.q) tags = tags.filter(name__icontains=self.q) # Aggregate querysets qs = QuerySetSequence(template_cats, tags) # qs = QuerySetSequence(tags) if self.q: # This would apply the filter on all the querysets qs = qs.filter(name__icontains=self.q) # This will limit each queryset so that they show an equal number # of results. qs = self.mixup_querysets(qs) return qs
def test_related_model(self): qss = QuerySetSequence(Article.objects.all(), BlogPost.objects.all()) self.assertTrue(qss.filter(publisher__name="Wacky Website").exists())
def test_related_model(self): qss = QuerySetSequence(Article.objects.all(), BlogPost.objects.all()) self.assertTrue(qss.filter(publisher__name="Wacky Website").exists())