In my base.html file, I am using
{% if user.is_authenticated %}
<a href="#">{{user.username}}</a>
{% else %} <a href="/acc/login/">log in</a>
Here, even if the user is logged in, the log in button shows up.
Now when I click on the log in link, it shows the username and also the normal login view, saying user is logged in.
So, what’s wrong?
Sounds like you’re not getting any user information in your templates. You need
'django.contrib.auth.middleware.AuthenticationMiddleware'in yourMIDDLEWARE_CLASSESsetting, and to get that goodness in context for your templates, you need to do:To save you doing this everywhere, consider using django-annoying’s
render_todecorator instead ofrender_to_response.