﻿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
6748	Ensure that debug error pages never evaluate QuerySets	Kenneth Arnold	Malcolm Tredinnick	"The local variable display on debug 500 pages unintentionally evaluates {{{QuerySets}}}. At best, the result is a delay ![1]. At worst, the attempted evaluation may cause another exception, which will mask the root cause of the error.

Based on my suggestions, Mike Axiak of MIT ESP wrote the attached code (originally bundled with [http://esp.mit.edu/code/browser/trunk/esp/esp/middleware/prettyerroremail.py other code]). I have attempted to factor out this part in a form that could conceivably apply to trunk. Patch attached.

![1] The load delay may be significantly greater than a normal page load, for two reasons:

1.  The debug page will include all local {{{QuerySets}}}, even if some of them were intermediary results in constructing the final {{{QuerySet}}}. This is particularly bad if the intermediate one does not yet have a row limit; I have occasionally found a debug page iterating over an entire huge table because of this.

2.  The model {{{__repr__}}} often returns {{{ForeignKey}}} fields that may not be used on the page. The patch doesn't address this yet."		closed	Core (Other)	dev		fixed	debug slow queryset repr memory	kenneth.arnold@… ehs@…	Design decision needed	1	0	0	0	0	0
