Answers for "django template if else elif"

1

elif in django template

{% for entry in entries %}
        {% if entry.category == 'General Member' %}
        <a href="{% url 'member:person-list' %}"><li>{{ entry.category }}</li></a>
    {% elif entry.category == 'Executive Committee Member' %}
        <a href="{% url 'member:execomember-list' %}"><li>{{ entry.category}}</li></a>
    {% else %}
    <a href="{% url 'member:person-list' %}"><li>{{ entry.category}}</li></a>
        {% endif %}
    {% empty %}
        <li>No recent entries</li>
  {% endfor %}
Posted by: Guest on May-11-2021
0

else if in django template

Your {% elif %} in {% if my video...%} doesn't have any condition.

I think you should have {% else %} instead?

{% if my_video %}//if that url is an link to video
    <img src="{{ my_video.thumbnail }}" class="img-rounded" alt="" height="75" width="75"/>
{% else %} //if that url isn't a video
    <img src="{{post.image}}"  class="img-rounded" alt=" EBAGU" height="75" width="75"/>
{% endif %}
Posted by: Guest on March-06-2021

Python Answers by Framework

Browse Popular Code Answers by Language