Django annotation multiply fields

When I try to annotate my model I face an issue that two fields multiply each other

def get_queryset(self):
return self.queryset.annotate(
    my_votes=Count("votes", filter=Q(votes=self.request.user), distinct=False)
    vote_count=Count("votes", distinct=False)
    comments_count=Count("comments", distinct=True)
)

I know that there is an issue with multiple aggregations

Combining multiple aggregations with annotate() will yield the wrong results because joins are used instead of subqueries

django docomentation

Is there another way to accomplish this?

Back to Top