Exercise 1: Why Chaining .filter().exclude() Doesn't Run Two Queries — Possible Solution ==================================================================== WHY TWO LINES DON'T MEAN TWO QUERIES ------------------------------ Per this chapter, a QuerySet is lazy - it only describes a query, it doesn't execute anything against the database the moment it's created or chained. qs = Page.objects.filter(...) doesn't run a query; it just builds a QuerySet object describing "find rows matching this filter." qs = qs.exclude(...) doesn't run a query either; it takes that existing description and refines it further into a new, still-unevaluated QuerySet describing both conditions combined. WHAT ACTUALLY TRIGGERS THE QUERY ------------------------------ Per this chapter, the query only actually runs once the QuerySet is evaluated - iterated over, converted with list(), sliced for display, or otherwise asked to actually produce real rows. At that point, Django combines everything that was chained onto it (the filter AND the exclude) into a single SQL query and sends it to the database exactly once - not once per chained method call. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly explains that QuerySets are lazy and that chaining .filter()/.exclude() only builds up a query description without executing anything, and correctly identifies evaluation (iteration, list(), etc.) as the actual trigger that runs the single combined query.