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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -