Django auth confusion in templates -
im playing django auth library, , ive come across dont understand.
i have master template base.html
, inside template have following code:
{% if user.is_authenticated %} welcome {{user.username}}, <a href='/accounts/logout/'>logout</a> {% else %} welcome guest, please <a href='/accounts/login/'>login</a> {% endif %}
this repeated on every page, in header. after ive logged in however, on login page itself, shows welcome guest...
string, if there no authenticated user.
confusingly however, auth library appears doing job elsewhere, cant access login protected functions, , can after ive logged in etc.
can tell me im going wrong?
from the docs:
technically, these variables made available in template context if use
requestcontext
,template_context_processors
setting contains"django.contrib.auth.context_processors.auth"
, default. more, see requestcontext docs.
Comments
Post a Comment