diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index a91dcb9d78..92e202edca 100644 --- a/django/conf/global_settings.py +++ b/django/conf/global_settings.py @@ -110,6 +110,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.auth', 'django.core.context_processors.debug', 'django.core.context_processors.i18n', +# 'django.core.context_processors.request', ) # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a diff --git a/django/core/context_processors.py b/django/core/context_processors.py index 201f786218..fc72aca6c8 100644 --- a/django/core/context_processors.py +++ b/django/core/context_processors.py @@ -38,6 +38,9 @@ def i18n(request): context_extras['LANGUAGE_CODE'] = LANGUAGE_CODE return context_extras +def request(request): + return {'request': request} + # PermWrapper and PermLookupDict proxy the permissions system into objects that # the template system can understand. diff --git a/docs/templates_python.txt b/docs/templates_python.txt index bbf7c8f745..efbd648cf1 100644 --- a/docs/templates_python.txt +++ b/docs/templates_python.txt @@ -329,6 +329,16 @@ See the `internationalization docs`_ for more. .. _LANGUAGE_CODE setting: http://www.djangoproject.com/documentation/settings/#language-code .. _internationalization docs: http://www.djangoproject.com/documentation/i18n/ +django.core.context_processors.request +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**New in Django development version** + +If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processor, every +``DjangoContext`` will contain a variable ``request``, which is the current +`HttpRequest object`_. Note that this processor is not enabled by default; +you'll have to activate it. + Loading templates -----------------