When Querysets Are Evaluated?

When QuerySet s are evaluated. Internally, a QuerySet can be constructed, filtered, sliced, and generally passed around without actually hitting the database. No database activity actually occurs until you do something to evaluate the queryset.

How does Django QuerySet work?

A django queryset is like its name says, basically a collection of (sql) queries, in your example above print(b. query) will show you the sql query generated from your django filter calls. Since querysets are lazy, the database query isn't done immediately, but only when needed - when the queryset is evaluated.

Does Values_list evaluate QuerySet?

len() : A QuerySet is evaluated when you call len() on it. This, as you might expect, returns the length of the result list. list() : Force evaluation of a QuerySet by calling list() on it.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.