[Answered ]-Django Template changing html attribute based on slug and current request

1👍

Try this:

<ul>
   {% for post in posts %}
   {% url "blog:entries" post=post as blog_entry %}
   <li><a href="/blog/{{post}}" {% if request.path == blog_entry %} class="active"{% endif %}>
   <span class="item">{{post}}</span>
   </a></li>
   {% endfor %}
</ul>

Leave a comment