Add new filter

This commit is contained in:
littlewolf 2019-09-27 17:12:12 +03:00
parent a0a6578ae8
commit 7a0999a520

View File

@ -49,6 +49,7 @@ class RelatedObjectsCountMixin(models.QuerySet):
return self._annotate_related_objects_count().filter(q_objects)
def filter_all_related_gt(self, count):
"""Queryset filter by all related objects count"""
exp =reduce(add, [F(f"{related_object}_count") for related_object in self._get_related_objects_names()])
return self._annotate_related_objects_count()\
.annotate(all_related_count=exp)\