Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print context content in the template?

Tags:

python

django

How can I print or iterate over all the variables available in the context from the template code?

I know about {% debug %} but it contains too much information. I'd just like to print variable names available in the current context.

Is there a way to do this without writing custom tag?

like image 388
Kugel Avatar asked Jan 04 '10 14:01

Kugel


People also ask

What is context in Django template?

A context is a variable name -> variable value mapping that is passed to a template. Context processors let you specify a number of variables that get set in each context automatically – without you having to specify the variables in each render() call.

What is context in Render?

What is the render context? The class RenderContext is automatically created by the graphics service. It is a collection of data that needs to be passed to every Render method. The render context should contain all information required to render an object or to perform a rendering step.

Which keyword is used to load another template in template file?

include tag loads a template and renders it with the current context. This is a way of “including” other templates within a template.


1 Answers

Use the Django debug toolbar - gives you this on the Templates tab, along a whole range of other useful debugging information.

like image 96
Daniel Roseman Avatar answered Nov 06 '22 23:11

Daniel Roseman