← 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
- When do you use selectrelated() vs prefetchrelated() in Django?
- In Django REST Framework ViewSets, which decorator is used to create a custom endpoint?
- What types of API versioning does Django REST Framework support?
- What are the first steps to debug performance issues in Django?
- Examples of Python stdlib modules runnable as scripts (python -m ...):
← PreviousNo login needed