1

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.

1 Answer 1

1

You should add request to context:

TEMPLATE_CONTEXT_PROCESSORS = (
 ...
 'django.core.context_processors.request',

)
Sign up to request clarification or add additional context in comments.

2 Comments

P.S. this is in django settings
stackoverflow.com/users/1134625/michael-plakhov Thx a ton. Also we need to put 'django.core.context_processors.auth' into TEMPLATE_CONTEXT_PROCESSORS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.