django addition -


how increment value of variable in template..??

{% s in list%}      {% subject in s%}              {% sub in subject %}                      <div id="{{ sub| getid:i }}"></div>                      # here want increment value of               {% endfor %}       {% endfor %} {% endfor %} 

if want increase i on nested loops, can pass stateful context variable, such i=itertools.count(), , in template, use

<div id="{{ sub| getid:i.next }}"></div> 

the django documentation on template language design states philosophy of template language that

the template system meant express presentation, not program logic.

and means cannot manipulate state directly filters. achieve state changes, have create own stateful variables state can altered via function call.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -