[Django]-What template is loaded by Django?

5๐Ÿ‘

  • First if you have set DEBUG = True django automatically gives you information about where django was looking for templates (in general and especially in case it didnโ€™t find one)

You should see something like this:
enter image description here

  • second you can add the popular django plugin django-debug-toolbar. It can show you for each request what templates were used and what their context was.

see: https://django-debug-toolbar.readthedocs.io/en/stable/panels.html#template

enter image description here

2๐Ÿ‘

Still, not exactly the answer, but something to get me closer. One could start Django shell, and then try this:

>>> from django.template.loader import get_template
>>> get_template('template/name').origin.name

to find out what template was actually used. This is still not enough to see though which templates were considered while resolving the template.

Leave a comment