Question

I have a html template as given below, i want to know what is the way for getting / debugging the values of django tags {% %} . I want to see the tags values at run time. e.g.

{% for category in categories %} {% for error in form.errors %}

<!DOCTYPE html>
<html>
    <head>
        <title>Rango</title>
    </head>

    <body>
        <h1>Rango says...hello world!</h1>

        {% if categories %}
            <ul>
                {% for category in categories %}
                <a href= 'tango/page_view'>
                    <li>
                     {{ category.name }} 
                    </li>
                </a>
                {% endfor %}
            </ul>
        {% else %}
            <strong>There are no categories present.</strong>
        {% endif %}

    </body>
</html>
Was it helpful?

Solution

This is a perfect use case for django-debug-toolbar.

Template panel shows templates and context used, and their template paths.

Or, alternatively, just print out the values you want to see:

{% for category in categories %}
    {{ category }}
    ...
{% endfor %}

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top