I have a model like:
class Questionnaire(models.Model):
YES_NO_CHOICES = (
(True, 'Yes'),
(False, 'No'),
)
satisfaction = models.BooleanField(choices=YES_NO_CHOICES, default=True)
register = models.DateField(auto_now_add=True)
I need to get responses from this questionnaire grouped by months and count "yes" and "no" responses.
Example, I have responses like this:
{
'2015-11-29': {True: 1, False: 2},
'2015-11-30': {True: 3, False: 1},
'2015-12-01': {True: 5, False: 2},
'2015-12-05': {True: 3, False: 6}
}
I need a django queryset to do something like:
{
{'2015-11-01': {True: 4, False: 3},
{'2015-12-01': {True: 8, False: 8}
}
The date is not important, in template I'll just use the month value (01, 02, 03, ..., 11, 12).
I'm searching for a pythonic way to do this, preferably with queryset in django, not dictionary.