Skip to content

Support for non-Django template systems #168

wants to merge 2 commits into from

4 participants


Django 1.2 introduced support for non-Django template systems. Unfortunately the instrumented test renderer is still Django specific. This branch updates the Template panel monkey patching to wrap template lookup and decorate the Template class' render method to emit the correct signal. This allows DjDT to work with non-Django template systems (tested with Mako templates).

nyergler added some commits May 20, 2011
@nyergler nyergler Non-Djano templates may not have a name or origin property. 3a0c2fc
@nyergler nyergler Replace find_template with a version that decorates Template classes.
find_template_and_decorate will decorate the render method of Template
classes in order to emit signals needed by Django Debug Toolbar.

I want it too


This code has been refactored since you filed the pull request. Do you know if the problem still exists in master?


After further code inspection, I believe the master branch doesn't support this use case yet.

@aaugustin should allow to reproduce this issue without writing too much code.


I spent some time on this issue today. Django's support for other template languages is documented here:

The debug toolbar performs two monkey-patches:

  • It modifies Template.__init__ to store the origin attribute. This isn't useful anymore in Django >= 1.7 because Django does it by itself.
  • It modifies Template.render to send the template_rendered signal before rendering a template. I could add this feature to Django, too.

Some libraries designed to integrate third-party template languages with Django have these features built-in:

If we look at the implementation, Django goes through through each template loader and calls it with the template name. The template object is returned by load_template. We can override that method. However, at this point, the template is already initialized. All we can do is alter the behavior of its render method.


Jinjo now supports working with the debug toolbar. I found another library that I was able to reproduce the issue with, django-jinja2.

Also, for future/other readers the issue isn't that an error occurs, it's that the template panel doesn't contain any information about the template or the context passed to it.


I'm going to close this in favor of #693. Sorry it didn't get merged.

@aaugustin aaugustin closed this Mar 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.