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 answers from this questionnaire, grouped by month, and count the answers "yes" and "no."
For example, I have answers 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 query set to do something like:
{
{'2015-11-01': {True: 4, False: 3},
{'2015-12-01': {True: 8, False: 8}
}
The date is not important, in the template I just use the value of the month (01, 02, 03, ..., 11, 12).
I am looking for a Python way to do this, preferably with a query in django, and not with a dictionary.