python - how to set custom forloop start point in django template -


there forloop in java can tell start , end:

for(int i=10;i<array.length;i++){  } 

but how can implement int i=10 in django template? how can set starting , ending point on own?

there forloop.first , forloop.last, defined inside loop , cannot this?:

{{forloop.first=10}}  {% athlete in athlete_list %}     <li>{{ athlete.name }}</li> {% endfor %}  {{forloop.last=20}} 

i read django doc feature seems not there

how using built-in slice filter:

{% athlete in athlete_list|slice:"10:20" %}     <li>{{ athlete.name }}</li> {% endfor %} 

if need make numeric loop (just python's range), need custom template tag, one: http://djangosnippets.org/snippets/1926/

see other range snippets:

also see:

by way, doesn't sound job templates - consider passing range view. and, fyi, there proposal make such tag, rejected because it trying lead programming in template. - think it.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -