How to query as GROUP BY in django?
If you mean to do aggregation you can use the aggregation features of the ORM: from django.db.models import Count result = (Members.objects .values(‘designation’) .annotate(dcount=Count(‘designation’)) .order_by() ) This results in a query similar to SELECT designation, COUNT(designation) AS dcount FROM members GROUP BY designation and the output would be of the form [{‘designation’: ‘Salesman’, ‘dcount’: 2}, … Read more