'Count() outputs list and not a dictionary in django
I don't know what's happening this might be easy but I am stuck. I have the below queryset
job_title = Employee.objects.filter().values('role__name').annotate(total=Count('id'))
output I get [{'tole__name': 'Manager', 'total':2}, {'role__name': 'Director': 3}]
now when I try to get the dictionary like {2, 3} using totals = job_title['total] I get an error
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
