I struggle with is_authenticated
returning True
when I have not logged in:
u = request.user if u.is_authenticated: raise Exception('I am said to be authenticated, but I really am not.')
To clarify, the Django debug view correctly identifies u
as AnonymousUser
:
u <django.contrib.auth.models.AnonymousUser object at 0x9e76f4cc>
Even stranger, inside the is_anonymous
template is_anonymous
fine:
{% if not request.user.is_authenticated %} We are anonymous. {% endif %}
Why is this?
source share