Submission.objects.values('user').annotate(Count('id'))
I want to get the count of Submissions for each user
But this returns me set of individual submission with count as 1
Output:
{'user': 1, 'id__count': 1}
{'user': 1, 'id__count': 1}
{'user': 1, 'id__count': 1}
{'user': 1, 'id__count': 1}
{'user': 2, 'id__count': 1}
{'user': 2, 'id__count': 1}
{'user': 3, 'id__count': 1}
Whereas the output that I want is:
{'user': 1, 'id__count': 4}
{'user': 2, 'id__count': 2}
{'user': 3, 'id__count': 1}
What am I doing wrong?
Please help