[Answer]-How to parameterize django aggregation?

1👍

You can do this with two queries:

YourObject.objects.filter(vote__up=True, group=some_group).annotate(total_votes_up=Count('vote'))
YourObject.objects.filter(vote__up=False, group=some_group).annotate(total_votes_down=Count('vote'))

But I think that should exist some more elegante way to do this.

Leave a comment