Maybe this is a bit silly question, but I did not find the answer. Is there a way to use incremented / decremented variables in django templates?
eg {{ some_variable + 1 }}
{{ some_variable + 1 }}
There is a filter built in add:
add
{{ some_variable|add:"1" }}
One way to do this is to use the django template filter.
https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-custom-template-filters
def inc(value): return value+1
and then:
{{ some_variable|inc }}
forloop.counter, .
{% for a in object_list %} {{ forloop.counter }} {% endfor %}