0
如果我在127.0.0.1:8000/posts/我的按钮是“活动”,但如果我在127.0.0.1:8000/profile/我的按钮“配置文件”处于活动状态,但按钮“发布”处于未激活状态。如何同时激活按钮配置文件和帖子?
如何同时激活按钮配置文件和帖子?
<div class="container" />
<div class="navbar" />
<div class="navbar-inner" />
<a class="brand {%if request.get_full_path == '/'%} active{%endif%} " href="/">Start</a>
<ul class="nav">
<li {%if request.get_full_path == '/post/'%}class="active"{%endif%}><a href="/post/">{% trans "Post" %}</a></li>
</ul>
<ul class="nav" />
<li {% if active == 1 %}class="active"{%endif%}><a href="/profile/">{% trans "Profile" %}</a>
</li>
<li {% if active == 2 %}class="active"{%endif%}><a href="/posts/">{% trans "Post" %}</a></li>
....
如果这是积极的:
<li {% if active == 1 %}class="active"{%endif%}><a href="/profile/">{% trans "Profile" %}</a>
这:
<li {%if request.get_full_path == '/post/'%}class="active"{%endif%}><a href="/post/">{% trans "Post" %}</a></li>
也必须积极
'active'的值在哪里设置?为什么你不能仅仅使用{%if request.get_full_path =='/ post /'%}而不是{%if active == 1%} – Charl
谢谢。我解决这个问题 – user1966421