Django

QuerySet laziness

A QuerySet builds a query without executing it until evaluated - iterated, sliced with a step, len(), list() or bool().

Why interviewers ask about it

Laziness is why chained filters cost nothing extra, and also why N+1 hides so well: the extra query fires at attribute access, far from where the queryset was defined.

This term is part of the free Python Full-Stack interview preparation module - browse the full glossary for every definition.