When running the following jinja code, I only get “Column info” printed. Why the index does not appears ?
{% for field in columns_form %} {% if 'title_' in field.name %} <td>Column {{ loop.index }} info</td> {% endif %} {% endfor %}
Advertisement
Answer
It sounds like the template is being treated as a Django template, not a Jinja template.
Using {{ loop.index }}
should work in a Jinja template, but wouldn’t work in a Django template, where you would use {{ forloop.counter }}
instead.