I have two models called User and Transaction . Here i want to get the all the users with total sum of the transaction amount where status is succe
User
Transaction
You can hit this query:
from django.db.models import Avg, Count, Min, Sum User.objects.filter(status="success").annotate(total_amount=Sum('transaction__amount'))