Pergunta

I have info in the django documentation to create my custom user profile, something pretty similar to what they show here, the problem is that when I am trying to access information about if the user is logged in like the following:

{% if request.user.is_authenticated %}           
    <li ><a href="/profiles/signout">Signout</a></li>
{% else %}
    <li ><a href="/profiles/signin/">Acceder</a></li>
    <li class="active"><a href="/profiles/signup/">Registrate</a></li>
{% endif %}

how I am supposed to access the information if the user is logged in with the new customised user.

Foi útil?

Solução

Change request.user.is_authenticated to just user.is_authenticated

When you include the middleware django.contrib.auth.context_processors.auth in the settings, the user object would be available in the template.

Read more here

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top