[Answered ]-Problem with tags in Django | used taggit for storing tags

1👍

After looking at GitHub code, there is a name field so it should be {% if tag.name == 'Tech' %} instead, like so:

<div id="tab-2" class="tab-pane fade show p-0">
 {% for event in events %}
 {% for tag in event.tags.all %}
 {% if tag.name == 'Tech' %}
   <div class="row g-3">
    <div class="col mb-5">
     <div class="d-flex h-100">
      <div class="flex-shrink-0">
       <img class="img-fluid" src="{{event.e_image.url}}" alt="" style="width: 430px; height: 350px;">
       <h4 class="bg-dark text-primary p-2 m-0">{{event.e_date}}</h4>
      </div>
      <div class="d-flex flex-column justify-content-center text-start bg-secondary border-inner px-4">
      <h5 class="text-uppercase">{{event.e_name}}</h5>
      </div>
     </div>
    </div>
   </div>
 {% endif %}
 {% endfor %}
 {% endfor %}        
</div>

The tag is an instance of the Tag model, so you should not compare it directly with string.

Leave a comment