For debugging purposes, I would like to have a variable in all my templates holding the path of the template being rendered. For example, if a view renders templates/account/logout.html I would like {{ template_name }} to contain the string templates/account/logout.html.
I don’t want to go and change any views (specially because I’m reusing a lot of apps), so the way to go seems to be a context processor that introspects something. The question is what to introspect.
Or maybe this is built in and I don’t know about it?
The easy way:
Download and use the django debug toolbar. You’ll get an approximation of what you’re after and a bunch more.
The less easy way:
Replace
Template.renderwithdjango.test.utils.instrumented_test_render, listen for thedjango.test.signals.template_renderedsignal, and add the name of the template to the context. Note thatTEMPLATE_DEBUGmust be true in your settings file or there will be no origin from which to get the name.