1👍
✅
Just output the {{ user.username }}
. If user is logged, some of auth middleware and django.contrib.auth.context_processors.auth
context processor are enabled then the username will be shown.
The middleware takes the user id from the session, loads the User
from the db and sets the request.user
attribute. Then context processor takes the request.user
attribute and injects it into the RequestContext as the user
variable.
To make the user
variable available in your template you should use the render()
shortcut. Or the render_to_response()
with the RequestContext
as the context_instance
argument.
Source:stackexchange.com