aggregate vs annotate
Summarize whole querysets or per-row.
Two Ways to Summarize
The ORM gives you two summary tools: aggregate collapses a whole queryset into one result, while annotate adds a value to each row.
What aggregate Returns
Calling aggregate ends the query and hands you a plain Python dictionary, not a queryset, so there is nothing left to filter afterward.
from django.db.models import Avg
Book.objects.aggregate(Avg("price"))
# {"price__avg": 24.5}