django

Django template loop n times

//CODE FOR VIEW
render(request, 'page.html', {'range': range(10)}) // TO START RANGE FROM ONE use range(1,11)


//CODE FOR TEMPLATE
{% for i in range %}
     ...
{% endfor %}

Code is used to loop n times in Django template. First, you have to pass 'range' variable from view and then you can access that in your template and loop through that.

Was this helpful?