[Answered ]-Unable to use user.username in base template

2👍

Change your code to

return render_to_response('login.html', c, 
            context_instance=RequestContext(request))

Without the context_instance django will not add default context processors data in the template context. So you are not getting user object in the template.

👤Rohan

0👍

Try {% if request.user.is_authenticated %} in your template.

👤Jingo

0👍

If you make sure that the django.contrib.auth.context_processors.auth processor is enabled, you should just have a user variable available in your templates.

This processor is enabled by default, but you might have disabled it if you have overwritten TEMPLATE_CONTEXT_PROCESSORS in your settings.

Leave a comment