﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30874	Allow disabling of lazy loading of model and related fields on querysets	Rowan Seymour	nobody	"Lazy field fetching can be super convenient but also a liability at scale. For example:


{{{
for book in Book.objects.only(""id"").all():
  book.author  # lazily fetches author field
  book.categories.all()  # lazily fetches related field
}}}

You might be trying to optimize your query by using `only` but then later you reference another field and don't realize there's now a new DB hit for every object you've loaded.

What would be really useful in situations like this to disable lazy fetching of fields and related fields, so if you haven't included them with `only` or `select_related`, the field access raises an exception.

{{{
for book in Book.objects(allow_lazy=False).only(""id"").all():
  book.author  # raises exception
}}}

Indicating that you need to correct the query..

{{{
for book in Book.objects(allow_lazy=False).only(''id"", ""author"").select_related(""categories"").all():
  book.author
  book.categories.all()
}}}

"	Uncategorized	closed	Uncategorized	2.2	Normal	duplicate			Unreviewed	0	0	0	0	0	0
