Can not parse the remainder: '==0' from 'data.tab_nid==0'

时间:2017-10-12 09:38:56

标签: python django django-templates

I my template, I want to give a class active:

<li>{% if data.tab_nid==0 %} class="active" {% endif %} </li>

But when I run the page I get the bellow error:

TemplateSyntaxError: Could not parse the remainder: '==0' from 'data.tab_nid==0'

2 个答案:

答案 0 :(得分:4)

{% if data.tab_nid == 0 %}

You should put space before and after ==

答案 1 :(得分:1)

You use == to check the value if is equal, you should put space around ==.

And you can also use ifequal

Just try this:

<li>{% ifequal data.tab_nid 0 %} class="active" {% endifequal %} </li>

From the document, you can find the ifequal & ifnotequal's explain.