I have a base template with a header include in it. The header include contains the code below.
However for some reason I get no output in between the if block, any reason why? ps no errors. The rest of the template outputs just fine.
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>
content of {% include ‘includes/header.html’ %} below…. everything shows just not the two login/logout links. take them out the block and they show. neither statement shows in the 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” is installed and sessions in enabled.
If I output {{ user }} i get AnonymousUser which is what I except, so, one would assume the ‘else’ condition would fire, however neither conditions seem to be met.
The request context is being passed also…
return render_to_response('pageRegistration.html', context,context_instance=RequestContext(request))
I believe there’s a syntax error in your code that passed by unnoticed:
should be:
Django template system probably looks for a regex
{%...%}, and as that didn’t match, it was regarded simply as text inside the{% if %}{% endif %}node.