Django debug displays all page variables

Is there a template tag (or any other trick) that I can use to display all the variables available on the page?

+60
variables debugging django templates
Feb 06 '10 at 17:37
source share
5 answers

If DEBUG is enabled, there the template tag is called {% debug%}

+86
Feb 06 '10 at 18:55
source share

There are several options (some of them are already listed earlier):

Usually, all debugging functions work only when the application is in DEBUG .

+60
Jan 18 '14 at 15:14
source share

the debug toolbar does all of this and much, much more. See screencast for more details. If you literally just want variables, you can try

assert False, locals() 

in your view

+10
06 Feb '10 at 17:41
source share

About the advice. Use textarea and automatically select onclick for easy copying:

 <textarea onclick="this.focus();this.select()" style="width: 100%;"> {% filter force_escape %} {% debug %} {% endfilter %}</textarea> 
+9
Jul 23 '14 at 12:47
source share

A slightly more complicated solution with the best rewards is to download the django-debug-toolbar (documentation here )

There is an option “Templates” with another parameter “Switch context”, and you can see all the variables transferred to your template, as well as the ability to see the code behind the template.

Example of django-debug-toolbar template debugging

+6
Jan 20 '15 at 2:49
source share



All Articles