we have write down this query in django
ManageInterview.objects.filter
(post_id=request.data['job_id'])
.order_by('-id')
.annotate(total=Count('pitcher_id'))
After print this we got this query
SELECT *, COUNT(`pitcher_invitations`.`pitcher_id`) AS `total` FROM
`pitcher_invitations` WHERE `pitcher_invitations`.`post_id` = 254555444
GROUP BY `pitcher_invitations`.`id`
ORDER BY `pitcher_invitations`.`id` DESC
We are doing group by
pitcher_id
but django query group by
pitcher_invitations.id
we want this query
select * from `pitcher_invitations` where `post_id` =254555444
group by `pitcher_id` order by `id` desc