Is user.authenticated Not Working in Django Template?
The reason is that it is not user.authenticated. It is user.is_authenticated.Saw this mistake very commonly made. So thought of mentioning here in case you have been stuck with this silly mistake. Good luck!
{% if user.is_authenticated %} <li class="nav-item"><a class="nav-link" href="{% url 'accounts:logout' %}">Log out</a></li>
{% else %} <li class="nav-item"><a class="nav-link" href="{% url 'accounts:signup' %}">Sign up</a></li>
<li class="nav-item"><a class="nav-link" href="{% url 'accounts:login' %}">Log in</a></li>
{% endif %}
Comments
Post a Comment