i want to compare do simple math in django template
like {% forloop.counter > 5 %} {% endfor %}
how do i achieve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.