Python
Python

Reputation: 41

django janja compare database value

I have some data store in the database In boolean. I want to check if the value is True pick the value and perform some action on it.

product: "{{DB_report_query.product.name}}"
{% if DB_report_query.product.summary  == True %}
{{DB_report_query.summary}}
{% endif %}

But this does not work.

Upvotes: 1

Views: 414

Answers (1)

Sunderam Dubey
Sunderam Dubey

Reputation: 8837

If it is a BooleanField then simply use the following:

{% if DB_report_query.product.summary %}
    {{DB_report_query.summary}}
{% endif %}

Upvotes: 0

Related Questions