Vivek
Vivek

Reputation: 341

Problem with Jinja code if condition in django web application

I am trying to use an if condition in html using jinja code, The Boolean value called "is_verified" is false. But the code prints exactly opposite of what it is expected to do, What's going wrong here?

{% for info in infos %}
{% if info.is_verified == "false" %}
<h4>Verification status: PENDING</h4>
{% else %}
<h4>Verification status: APPROVED</h4>
{% endif %}
{% endfor %}

enter image description here

Upvotes: 0

Views: 172

Answers (1)

Irfan wani
Irfan wani

Reputation: 5075

You are comparing it with a string "false". Instead, use this;

{% for info in infos %}
{% if info.is_verified %} 
<h4>Verification status: APPROVED</h4>
{% else %}
<h4>Verification status: PENDING</h4>
{% endif %}
{% endfor %}

Upvotes: 3

Related Questions