I'm trying to run this code in my django template:
我正在尝试在我的django模板中运行此代码:
{% if lawChoice.releveAnnee==law.releveAnnee %}
I get the following error:
我收到以下错误:
Could not parse the remainder: '==law.releveAnnee' from 'lawChoice.releveAnnee==law.releveAnnee'
I think law.releveAnnee is considered as an object, not as an integer, that's why the comparison fails!
我认为law.releveAnnee被视为一个对象,而不是一个整数,这就是比较失败的原因!
Thanks in advance for your help,
在此先感谢您的帮助,
Romain
EDIT
Thanks to the answer above: a SPACE is needed BEFORE and AFTER the ==:
感谢上面的答案:在==之前和之后需要一个空格:
{% if lawChoice.releveAnnee == law.releveAnnee %}
This works! Solved :)
这有效!解决了 :)
1 个解决方案
#1
1
Probably that's because you need to add a space before and after the ==
operator.
可能是因为你需要在==运算符之前和之后添加一个空格。
You'd better go for ifequal
你最好去ifequal
{% ifequal lawChoice.releveAnnee law.releveAnnee %}
...
{% endifequal %}
#1
1
Probably that's because you need to add a space before and after the ==
operator.
可能是因为你需要在==运算符之前和之后添加一个空格。
You'd better go for ifequal
你最好去ifequal
{% ifequal lawChoice.releveAnnee law.releveAnnee %}
...
{% endifequal %}