I have this simple SQL query –
SELECT pid, COUNT(*) AS docs FROM xml_table WHERE suid='2' GROUP BY pid;
How do I get this using Django ORM (i.e. django models). Basically I am not getting how to do GROUP BY?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
XML_table.objects.filter(suid='2').values('pid').annotate(docs=Count('pid')).order_by()Docs