examerioLogin
← Backend PythonQuestion 49 of 49

When is annotate() guaranteed to generate a GROUP BY in Django ORM?

📘 Explanation

An aggregate function like Count, Sum, Avg, Max, or Min is what triggers a GROUP BY in annotate(), and whether values() is placed before or after annotate() determines the grouping columns versus just the output shape. The wrong answers either claim GROUP BY always happens regardless of aggregates, invent a subquery fallback, or claim grouping is always on the primary key, none of which match Django's actual behavior.

Related questions

← PreviousNo login needed