user956424
user956424

Reputation: 1609

How can I access request object in django model admin change_form.html?

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.

Upvotes: 1

Views: 745

Answers (1)

Michael Plakhov
Michael Plakhov

Reputation: 2291

You should add request to context:

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

)

Upvotes: 1

Related Questions