I wish to access the currently logged in user while overriding the change_form.html for a django model in my project. I want to access the request.user.username in this form. How do I access this. I do not want to write a custom view for the same. In this template I wish to access it as {{ request.user.username }}. How do I do it? I am using Django version 1.6.5.
Add a comment
|
1 Answer
You should add request to context:
TEMPLATE_CONTEXT_PROCESSORS = (
...
'django.core.context_processors.request',
)
2 Comments
Michael Plakhov
P.S. this is in django settings
user956424
stackoverflow.com/users/1134625/michael-plakhov Thx a ton. Also we need to put 'django.core.context_processors.auth' into TEMPLATE_CONTEXT_PROCESSORS