I Didn't Know Querysets Could do That
summary
Shows concrete QuerySet recipes: use F() and Q() to build atomic, single‑SQL operations (e.g. Sum(F('unit_price') F('quantity'), output_field=FloatField()) to compute item totals), use select_related/prefetch_related to eliminate N+1 queries, use in_bulk* to get id→model maps, use only/defer to fetch fewer columns, use ExpressionWrapper and DB functions for inline transforms, and fall back to extra/raw SQL when native expressions can’t express the query. Examples run and avoid Python loops and race conditions.
AI-written summary · about
chapters (9)
- 0:00Start
- 1:58REFERENCE MODELS
- 8:41EXAMPLE: OR QUERIES
- 10:46EXAMPLE: QUERY ARITHMETIC
- 12:48EXAMPLE: INLINE REFERENCES
- 14:02QUERY EXPRESSIONS
- 16:33EXAMPLE: ORDER TOTALS (REDUX)
- 18:38EXTRA
- 20:13LET'S RECAP
related talks
29mMaking smarter queries with advanced ORM resources
27mDjango - Customise your SQL
26mA Related Matter: Optimizing your webapp
25mHunting for Treasure in Django
23mOptimizing your webapp by using django-debug-toolbar
35mDjango's GeneratedField
32mEasy, Breezy, Beautiful... Django Unit Tests with Colleen Dunlap
42mElasticsearch DSL
