← Fullstack with Vue.jsQuestion 53 of 62
What does Django's extra() method do, and when would you use it?
📘 Explanation
extra() is a queryset method for injecting raw SQL fragments when the ORM alone can't express a query, though it's discouraged in favor of annotate() and database functions. The wrong answers invent unrelated purposes like enforcing Meta constraints, joining many-to-many models, or attaching post-processing Python hooks.
Related questions
- When do you use selectrelated() vs prefetchrelated() in Django?
- What's the difference between annotate() vs values().annotate() in Django ORM?
- Given a Book model with a ForeignKey to Author, how do you query the most expensive book per author in Django ORM?
- What does QuerySet.defer() do in Django ORM?
- When you call selectrelated("author") on a Book queryset, what kind of SQL join does Django generate? Does it always…
← PreviousNo login needed