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 %}
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

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