简体   繁体   中英

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?

如果您在settings.py TEMPLATE_CONTEXT_PROCESSORS中添加了'django.core.context_processors.request'则应该可以在管理模板中使用该请求

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM