I have a following model:
class VotingRound(models.Model):
pass # here are some unimportant fields
class Vote(models.Model):
voting_round = models.ForeignKey(VotingRound)
vote = models.CharField(choices=...)
Now I have instance of VotingRound and I would like to get to know how many times was each value represented. This is easily done through collections.Counter:
>>> Counter(voting_round_instance.vote_set.values_list('vote', flat=True))
Counter({u'decline': 8, u'neutral': 5, u'approve': 4})
Now I would like to know if there is a way to do this with Django aggregation techniques....
I have found this module, but before using it I wanted to know if there is native way to do it.