here is my queryset
queryset = (PrathamTeamMembers.objects.
select_related('state', 'district', 'block', 'personnel_type').
filter(is_active=1).
annotate(total_state=Count('state', distinct=True),
total_district=Count('district', distinct=True)))
I am expecting result similar to
{
"total_state": 10
"total_district": 60
}
But it is not aggregating instead it is grouping by table PrathamTeamMembers
primary key. which I want to avoid. Since it is grouping on table primary key so my queryset giving result simlary to ..
[{
"total_state": 1,
"total_district": 1
},
{
"total_state": 1,
"total_district": 1
},
{
"total_state": 1,
"total_district": 1
}
]