{% if forloop.counter0|divisibleby:2 %}
<# dispaly one , 0,2,4,6 .... #>
{% else%}
<# dispaly another 1,3,5,7,#>
{% endif %}
We also can custom filter,like this :
new a file named templatehelper.py
code below>>
@register.filter
def div(value, div):
'''
:param value:
:param div:
:return:
'''
return round((value / div), 2)
load in your template head>>
{% load templatehelper %}
{% if forloop.counter0|divisibleby:2 %} <# dispaly one , 0,2,4,6 .... #> {% else%} <# dispaly another 1,3,5,7,#> {% endif %}
We also can custom filter,like this : new a file named templatehelper.py code below>> @register.filter def div(value, div): ''' :param value: :param div: :return: ''' return round((value / div), 2) load in your template head>> {% load templatehelper %}
if amount is 25, the result will be 0.25