F
F
Friend2016-11-19 17:11:38
Django
Friend, 2016-11-19 17:11:38

How to make calculations on the html side?

For example, in python, you can build a condition with calculations

a = 10
b = 2
for i in a:
  if i%b == 0:
    print("ПриветПока")

Is it possible to implement such a condition on the html side in Django if i%b == 0 ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mintormo, 2016-11-19
@Mintormo

As I understand it, you need to make a conclusion in the template, taking into account the mentioned condition. Then you can try like this.

{{ if i|divisibleby:"b" }}
...
{{ endif }}

If a number is evenly divisible, then the remainder of the division is zero. As you need.
Here is the link .
Loops can also be implemented in templates.

O
Optimus, 2016-11-19
Pyan @marrk2

HTML does not calculate anything, only on JS if calculated and displayed in html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question