Guided Notes
QuerySets
Getting, filtering, excluding, ordering, and slicing data, field lookups, values, and following relationships.
What is a QuerySet?
Slide 1 / 5A QuerySet is a collection of objects from the database, built with Model.objects:
Book.objects.all() ā every book.
QuerySets are lazy: building one doesn't touch the database. The SQL runs only when you use the results ā loop over them, print them, count them, or slice them. You can chain methods to refine a query step by step, and Django combines them into one SQL statement.
