Add annotate to filter

This commit is contained in:
littlewolf 2019-09-27 12:01:11 +03:00
parent 44f792db0c
commit 910322273e
2 changed files with 1 additions and 2 deletions

View File

@ -46,7 +46,6 @@ class CollectionHomePageView(CollectionViewMixin, generics.ListAPIView):
"""Override get_queryset method"""
queryset = models.Collection.objects.published()\
.by_country_code(code=self.request.country_code)\
.annotate_related_objects_count()\
.filter_related_gt(3)\
.order_by('-on_top', '-modified')

View File

@ -43,4 +43,4 @@ class RelatedObjectsCountMixin(models.QuerySet):
for related_object in self.get_related_objects_names():
q_objects.add(Q(**{f"{related_object}_count__gt": count}), Q.OR)
return self.filter(q_objects)
return self.annotate_related_objects_count().filter(q_objects)