2👍
✅
Username is accessible as an attribute (request.user
is either auth.User
instance, or AnonymousUser
instance with similar interface). Try this:
if request.user.is_authenticated()
context.update({'username': request.user.username})
Source:stackexchange.com