I am trying to use a for loop in my template but I am getting an error.
Here is the Jinja:
{% for i in range(1,10) %}
<h2>{{i}}</h2>
{% endfor %}
Here is the error:
django.template.exceptions.TemplateSyntaxError: Could not parse the remainder: '(1,10)' from 'range(1,10)'
I am a little confused. This indicates that there is something wrong with range
or even that it doesn't exist, yet I have seen it suggested as a solution in other Stack Overflow posts such as this one:
How to simulate while loop in Jinja2
Does range exist in Jinja/Django? If yes, why is this not working, and if no, what is the best alternative?