Opened 10 years ago

Closed 10 years ago

#2565 closed enhancement (fixed)

Documentation should clarify lazy nature of querysets

Reported by: Simon Willison Owned by: Jacob
Component: Documentation Version:
Severity: normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I've answered a couple of comments in the documentation recently about QuerySet lazy evaluation:

http://www.djangoproject.com/documentation/tutorial4/#c2024
http://www.djangoproject.com/documentation/models/pagination/#c2032

That's enough for me to think that this is a frequent misunderstanding. We certainly don't want people to be put off Django because they think it makes horribly inefficient queries, when the exact opposite is true!

An entry in the FAQ would be a good start, but having notes (and a link) about this behaviour in the relevant places in the docs would be smart too.

Attachments (1)

2565.diff (1.4 KB) - added by James Bennett 10 years ago.
Patch adding an explanation that all() doesn't query

Download all attachments as: .zip

Change History (5)

comment:1 Changed 10 years ago by James Bennett <ubernostrum@…>

So a link from various places to this: http://www.djangoproject.com/documentation/db_api/#querysets-are-lazy might solve it?

comment:2 Changed 10 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedAccepted

Where should this be mentioned? possibly the best place would be to have a chained filter example in tutorial 1 and a comment/link to the db-api doc.

Changed 10 years ago by James Bennett

Attachment: 2565.diff added

Patch adding an explanation that all() doesn't query

comment:3 Changed 10 years ago by James Bennett

Triage Stage: AcceptedReady for checkin

comment:4 Changed 10 years ago by Jacob

Resolution: fixed
Status: newclosed

(In [4637]) Fixed #2565: added a note about the laziness of querysets in tutorial 4. Thanks, Ubernostrum.

Note: See TracTickets for help on using tickets.
Back to Top