Code

Opened 8 years ago

Closed 7 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 ubernostrum 7 years ago.
Patch adding an explanation that all() doesn't query

Download all attachments as: .zip

Change History (5)

comment:1 Changed 8 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 7 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Accepted

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 7 years ago by ubernostrum

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

comment:3 Changed 7 years ago by ubernostrum

  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 7 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.