Reputation: 5540
I need to display a portion of HTML on the following condition,
var1=="google" and var2 is True
I wrote the following code ,
{% ifequal var1 "google" and var2 %}
/*HTML CODE */
{% endif %}
and i got an error
TemplateSyntaxError at /process/apply.html
u'ifequal' takes two arguments
I know i can split the above two nested IF statements,still is there a way in django to combine them to a single if statement?
Upvotes: 0
Views: 1900
Reputation: 53326
From django ifequal documentation
It is only possible to compare an argument to template variables or strings. You cannot check for equality with Python objects such as True or False. If you need to test if something is true or false, use the if tag instead.
So if you want to check for True
or False
, so need to use if
.
{%if var1 == "google" and var2 %}
....
{%endif%}
Upvotes: 1