I understand that request.path will give me the current URL.
I am currently working on my base.html template with CSS tabs and I want the template to know which tab is currently “active” and pass class="active-tab" to an <a> tag.
So I wanted to do something like
<a href="{% url orders_list %}"
{% if request.path = reverse('orders_list') %}
class="active-tab"
{$ endif %}
>Orders</a>
But I’m sure you can’t do that if comparison. I also only want the base (?) URL ignoring any GET parameters.
Any suggestions or tips also welcomed. Thanks in advance!
You can use a custom template tag
Then usage is sort of like this in your template:
You can modify the template tag as you wish.