我有一个包含标题的基本模板。标头包含以下代码。
但是由于某种原因,我在 if 块之间没有输出,为什么?ps没有错误。模板的其余部分输出就好了。
base.html
<body>
{% include 'includes/header.html' %}
{% block sliderWrapper %}{% endblock %}
{% block titleWrapper %}{% endblock %}
<div id="wrapper">
<div class="container">
{% block mainWrapper %}{% endblock %}
</div>
</div>
{% include 'includes/footer.html' %}
{% include 'includes/copyright.html' %}
{% include 'includes/js.html' %}
</body>
{% include 'includes/header.html' %} 下面的内容....一切都只显示了两个登录/注销链接。把他们带出街区,他们就会展示出来。两个语句都没有显示在 if
<div class="span9">
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="/">Home</a></li>
<li><a href='{% url django.contrib.flatpages.views.flatpage url="how-it-works/" %}'>How does it work?</a></li>
<li><a href='{% url django.contrib.flatpages.views.flatpage url="how-it-works/" %}'>Download</a></li>
<li><a href="/member/registration/">Register</a></li>
{% if user.is_authenticated %}
<li><a href="/member/logout/">Logout</a></li>
{% else % }
<li><a href="/member/login/">Login</a></li>
{% endif %}
</ul>
</div>
</div>
</div>
“django.contrib.auth.context_processors.auth”已安装并启用会话。
如果我输出{{ user }}
我会得到 AnonymousUser,这是我所不知道的,所以,人们会假设“else”条件会触发,但似乎没有满足任何条件。
请求上下文也被传递...
return render_to_response('pageRegistration.html', context,context_instance=RequestContext(request))