Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare variables in Django Templates

I have two variables in my Django template file

like

{{orderitem.value.id}}

and `

{{ orderitem.order.id }}

I need to show some data if they are equal but i don’t know how to compare variables in html files .

please suggest.

like image 751
user2106353 Avatar asked Jan 14 '23 12:01

user2106353


1 Answers

use ifequal tag to compare variables in templates:

sample:

{% ifequal orderitem.value.id orderitem.order.id %}
    <p>are equals!<p/>
{% endifequal %}
like image 148
ksysctl Avatar answered Jan 22 '23 19:01

ksysctl