[Answered ]-Why is request.user.is_authenticated printing out false even when user is logged in and rendering template

1👍

You likely made a GET request, the form should be:

<form method="POST" action="{% url 'logout' %}">
    {% csrf_token %}
    <button type="submit">logout</button>
</form>

Likely the method="POST" is lacking, so it makes a GET request. Logging in/out should be done through a POST request, since this changes the state.

I checked the database and the column, is_authenticated is still FALSE.

Normally the User model does not have a column named is_authenticated. This is not a database column, this is simply true for all Users. If the user is not logged in, request.User will return the AnonymousUser object, which has is_authenticated returning False.

Leave a comment