How about using built-in slice filter:
{% for athlete in athlete_list|slice:"10:20" %}
<li>{{ athlete.name }}</li>
{% endfor %}
If you need to make a numeric loop (just like python's range
), you need a custom template tag, like this one: http://djangosnippets.org/snippets/1926/
See other range
snippets:
Also see:
By the way, this doesn't sound like a job for templates - consider passing a range from the view. And, FYI, there was a proposal to make such tag, but it was rejected because it is trying to lead to programming in the template.
- think about it.