erimar77
erimar77

Reputation: 213

Django if statement not correct

I'm not sure where I'm going wrong with this. I have a loop that's printing out a couple of email addresses. I want to set one as the "primary" address based on it's status of primary or not. If I give the template {{ x.primary }} I get the values of True or False.

I'd like my output to look like:


<ul>
{% for x in member.person.email_addresses.all %}
    {% if x.publish %}
       <li> {{ x.type }}: {{ x.email }} {% if x.primary == "True" %} (Primary) {% endif %} </li>
    {% endif %}
{% endfor %}
</ul>

Upvotes: 1

Views: 131

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239290

Don't quote True. It's just True:

{% if x.primary == True %}

Or more simply:

{% if x.primary %}

Upvotes: 5

Related Questions