Chrome Extension

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 faster with devsheet chrome extension and increase productivity as a programmer
search code from your favorite search engine instantly.
Install Now

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?
0 Comments
Open Code Manager We are hiring