[Fixed]-Django template tag to recurse a nested dict

1👍

You might be able to do with a template include:

recurse_dict.html

{% if dict and dict.keys|length > 0 %}
<ul>
    {% for key, value in dict.items %}
        <li>
            {% if value and value.keys|length > 0 %}
               {{ key }} {% include "recurse_dict.html" with dict=value %}
            {% else %}
               {{ value }}
            {% endif %}
        </li>
    {% endfor %}
</ul>
{% endif %}

Leave a comment