# If you mean to do aggregation you can use the aggregation features of the ORM:
from django.db.models import Count
Members.objects.values('designation').annotate(dcount=Count('designation'))
# 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},
{'designation': 'Manager', 'dcount': 2}]
from django.db.models import Avg
teams = Analysts.objects.values('class').annotate(avgcap=Avg('gpa'))
# Assuming Analysts model has class and gpa field..
# This will group by class field and give the avg of gpa field values
Transaction.objects.all().values('actor').annotate(total=Count('actor')).order_by('total')
Transaction.objects.all().values('actor').annotate(total=Count('id')).order_by('total')