when I put <p>{{clothes.brand}}</p>
in django template, it shows up “Tommy” on the page, but when write
{% if clothes.brand == "Tommy" %}
<p>This is the product</p>
{% endif %}
it shows nothing instead.
May I ask where went wrong of my code?
when I put <p>{{clothes.brand}}</p>
in django template, it shows up “Tommy” on the page, but when write
{% if clothes.brand == "Tommy" %}
<p>This is the product</p>
{% endif %}
it shows nothing instead.
May I ask where went wrong of my code?
First thought that comes to mind is that there could be spaces before or after “Tommy” in clothes.brand. I would examine the rendered output to see if you’re getting <p>Tommy</p>
or if you’re actually getting something like <p>Tommy </p>
, the latter of which would not be equal to “Tommy”. (There could also be other non-printable characters in that variable that would invalidate that condition.)