The mathematical comparison used in Django.96 templates.

I want to compare simple math in a django template

like {% forloop.counter> 5%} {% endfor%}

How do I achieve this?

+1
source share
1 answer

This is not possible because Django intentionally provides very limited syntax that does not include mathematical operators. You can do this by creating a custom template filter , but this is a bad idea - you would be better off pre-processing the data before passing it to so you don't need a math operator. This, of course, is what Django wants you to do.

+1
source

Source: https://habr.com/ru/post/1752501/


All Articles