Reputation: 717
I read this and my code looked like this:
html:
<li {% if request.path == '/groups/{{ group.id }}/' %}class="active"{% endif %} ><a href="{% url 'detail' group.id %}">Link</a></li>
The only problem is that /groups/{{ group.id }}/
obviously turn into:
/groups/{{ group.id }}/
not
/groups/1/
that will end up being a lot of code if type it for the other 10 links on the page.
Upvotes: 1
Views: 140
Reputation: 43300
Instead of hardcoding the url, use the url
tag with as
{% url 'my_group_url_name' group.id as group_url %}
{% if request.path == group_url %}
Upvotes: 4