user7486109
user7486109

Reputation:

django how to display a tag only if the value coming from the database is not null?

The logic for showing a tag

{% if profile.facebook is not None %}<i class="facebook icon"></i>{% endif %}

i want to show the facebook icon only when the user has provided the link. if not i dont want to display the icon.

Upvotes: 0

Views: 54

Answers (1)

Brian Ocampo
Brian Ocampo

Reputation: 1515

You can define your conditional as well:

{% if profile.facebook %}
    <i class="facebook icon"></i>
{% endif %}

if your code not work, you can share more info, like your views.py etc.

Upvotes: 2

Related Questions