How do I write a numeric for
loop in a Django template? I mean something like
for i = 1 to n
You should use "slice" in template, a example like this:
in views.py
contexts = {
'ALL_STORES': Store.objects.all(),
}
return render_to_response('store_list.html', contexts, RequestContext(request, processors=[custom_processor]))
in store_list.html:
{% for store in ALL_STORES|slice:":10" %}
- {{ store.name }}
{% endfor %}