I am making the navigation of the page as active by checking if the url matches with the current url.
<li>
{% url 'blog' as blog_url %}
<a href="{{blog_url}}" {% if request.get_full_path == blog_url %}class="active"{% endif %}>Blog</a>
</li>
Now I am using pagination, which when going to different page results in url being like this:
From /blog/
to
/blog/?page=2
/blog/?page=3
And the above code does not work. So is there anyway to use regex in the template to get anything (like /blog/*
) and make it as active. Your help and guidance will be very much appreciated. Thank you.