Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin template: Accessing request object in template

I need the request object in all admin templates. In frontend templates, I can achieve this by rendering the template with RequestContext:

return render_to_response('my_template.html',
    my_data_dictionary,
    context_instance=RequestContext(request)
)

With that, I can access the request object in frontend:

{{ request.path }}

How can I do this for all admin views in Django 1.2?

like image 723
Martin Avatar asked Jul 02 '12 07:07

Martin


1 Answers

The request should be available in the admin templates if you have 'django.core.context_processors.request' added to your TEMPLATE_CONTEXT_PROCESSORS in your settings.py

like image 56
Timmy O'Mahony Avatar answered Oct 21 '22 13:10

Timmy O'Mahony