Skip to content

Template Panel Bugfix #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions debug_toolbar/panels/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@
# e-mail interception, which we don't want
from django.test.utils import instrumented_test_render
from django.template import Template
if Template.render != instrumented_test_render:
Template.original_render = Template.render
Template.render = instrumented_test_render

# django 1.1 instrumented_test_render patches Template.render.
# django 1.2 instrumented_test_render patches Template._render.
# if _render exists, we will patch that (1.2), otherwise we
# patch the render method.
patchee = '_render' if hasattr(Template, '_render') else 'render'
original_render = getattr(Template, patchee)
if original_render != instrumented_test_render:
Template.original_render = original_render
setattr(Template, patchee, instrumented_test_render)

# MONSTER monkey-patch
old_template_init = Template.__init__
def new_template_init(self, template_string, origin=None, name='<Unknown Template>'):
Expand Down