开发者

Math comparison operating in Django .96 templates

开发者 https://www.devze.com 2023-01-05 10:47 出处:网络
i want to compare do simple math in django template like {% forloop.counter > 5 %} {% endfor %} how do 开发者_StackOverflow社区i achieve this?This isn\'t really possible, because Django deliberately

i want to compare do simple math in django template

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

how do 开发者_StackOverflow社区i achieve this?


This isn't really possible, because Django deliberately provides a very limited syntax, which doesn't include math operators. You could do this by writing a custom template filter, but it's a poor idea - you'd be better off preprocessing the data before passing it in so you don't require the math operator. That's certainly what Django wants you to do, anyway.

0

精彩评论

暂无评论...
验证码 换一张
取 消