In a template, how do I get what page I'm currently on? I'd rather not pass a variable like page
, especially when I know some request.xxx
can provide me with the information.
<li {% if page=="home" %}class="active"{% endif %}>
<a href="/">Home</a>
</li>
<li {% if page=="about" %}class="active"{% endif %}>
<a href="/about">About</a>
</li>
As long as you've imported request
, request.path
should contain this information.