What is the difference between annotate() and aggregate() in the Django ORM?
Last updated
aggregate()computes one summary value over the whole queryset and returns a dict (terminal, ends the queryset).annotate()attaches a computed value to each object and returns a queryset you can keep filtering or ordering.Combining
annotate()withvalues()produces GROUP BY aggregates per group.