Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the current request from a RequestContext?

Tags:

django

Does a Django RequestContext have a way to get the HttpRequest object with which it is associated with? Does it have a method like get_request() or the like to get the request which is passed into the constructor? I need to reference it from a method in which I only receive the RequestContext.

like image 658
Naftuli Kay Avatar asked Mar 19 '26 19:03

Naftuli Kay


1 Answers

Add 'django.core.context_processors.request' to TEMPLATE_CONTEXT_PROCESSORS settings. And get request where context is available using :

request = context['request']
like image 67
Hanson Avatar answered Mar 21 '26 10:03

Hanson