from django.db.models import Sum result = Books.objects.values('author') .order_by('author') .annotate(total_price=Sum('price'))