django-debug-toolbar/django-debug-toolbar — pull request #565 by living180 (2014-03-20 21:45:55+00:00)
Title: Don't run context processors for redirect template.

In certain configurations, applying the context processors when rendering the redirect template can cause exceptions. For example, assume the folllowing Django settings:

APPEND_SLASH = True

MIDDLEWARE_CLASSES = (
'debug_panel.middleware.DebugPanelMiddleware',
'django.middleware.common.CommonMiddleware',
...
'custom.middleware.CustomMiddleware'
)

TEMPLATE_CONTEXT_PROCESSORS = (
...
'custom.context_processors.custom',
....
)

Further, assume that `custom.middleware.CustomMiddleware` sets an attribute on the request that `custom.context_processors.custom` tries to access. If `django.middleware.common.CommonMiddleware` causes a redirect, (e.g. as a result of the `APPEND_SLASH` setting), the attribute that `custom.context_processors.custom` needs will never get set on the request. Then when initializing the `RequestContext` in order to render `debug_toolbar/redirect.html`,an exception will occur when `custom.context_processors.custom` tries to access the missing attribute.

Since no context processors are needed to render the `debug_toolbar/redirect.html` template, avoid this problem by replacing `render` with `render_to_response`, which does not apply context processors to the template context.