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?
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 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.
include tag loads a template and renders it with the current context. This is a way of “including” other templates within a template.
Use the Django debug toolbar - gives you this on the Templates tab, along a whole range of other useful debugging information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With