hopieman
hopieman

Reputation: 389

Compare variable with character

Hello I'm using django templating with this template:

{% if material.unit =='U' %} 
    p/(u)
{% endif %}
{% if material.unit == 'M' %} 
    p/(m)
{% endif %}

I want to print p/(u) when variable material.unit is 'U' and p/(m) when is 'M'. This is not working properly. Is giving me this error:

Could not parse the remainder: '=='U'' from '=='U''

Upvotes: 0

Views: 21

Answers (1)

Alasdair
Alasdair

Reputation: 308939

Add a space after ==:

{% if material.unit == 'U' %} 

Upvotes: 1

Related Questions