mirror of https://github.com/django/django.git
Fixed #1278 -- Added a context processor that puts MEDIA_URL in the context, and added that context processor to the default set. Thanks to Ubernostrum for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5379 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
c84ff156c1
commit
d9f6470f2d
|
@ -144,6 +144,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
||||||
'django.core.context_processors.auth',
|
'django.core.context_processors.auth',
|
||||||
'django.core.context_processors.debug',
|
'django.core.context_processors.debug',
|
||||||
'django.core.context_processors.i18n',
|
'django.core.context_processors.i18n',
|
||||||
|
'django.core.context_processors.media',
|
||||||
# 'django.core.context_processors.request',
|
# 'django.core.context_processors.request',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,13 @@ def i18n(request):
|
||||||
|
|
||||||
return context_extras
|
return context_extras
|
||||||
|
|
||||||
|
def media(request):
|
||||||
|
"""
|
||||||
|
Adds media-related context variables to the context.
|
||||||
|
|
||||||
|
"""
|
||||||
|
return {'MEDIA_URL': settings.MEDIA_URL}
|
||||||
|
|
||||||
def request(request):
|
def request(request):
|
||||||
return {'request': request}
|
return {'request': request}
|
||||||
|
|
||||||
|
|
|
@ -776,7 +776,8 @@ Default::
|
||||||
|
|
||||||
("django.core.context_processors.auth",
|
("django.core.context_processors.auth",
|
||||||
"django.core.context_processors.debug",
|
"django.core.context_processors.debug",
|
||||||
"django.core.context_processors.i18n")
|
"django.core.context_processors.i18n",
|
||||||
|
"django.core.context_processors.media")
|
||||||
|
|
||||||
A tuple of callables that are used to populate the context in ``RequestContext``.
|
A tuple of callables that are used to populate the context in ``RequestContext``.
|
||||||
These callables take a request object as their argument and return a dictionary
|
These callables take a request object as their argument and return a dictionary
|
||||||
|
|
|
@ -294,7 +294,8 @@ return a dictionary of items to be merged into the context. By default,
|
||||||
|
|
||||||
("django.core.context_processors.auth",
|
("django.core.context_processors.auth",
|
||||||
"django.core.context_processors.debug",
|
"django.core.context_processors.debug",
|
||||||
"django.core.context_processors.i18n")
|
"django.core.context_processors.i18n",
|
||||||
|
"django.core.context_processors.media")
|
||||||
|
|
||||||
Each processor is applied in order. That means, if one processor adds a
|
Each processor is applied in order. That means, if one processor adds a
|
||||||
variable to the context and a second processor adds a variable with the same
|
variable to the context and a second processor adds a variable with the same
|
||||||
|
@ -390,6 +391,15 @@ See the `internationalization docs`_ for more.
|
||||||
.. _LANGUAGE_CODE setting: ../settings/#language-code
|
.. _LANGUAGE_CODE setting: ../settings/#language-code
|
||||||
.. _internationalization docs: ../i18n/
|
.. _internationalization docs: ../i18n/
|
||||||
|
|
||||||
|
django.core.context_processors.media
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processors, every
|
||||||
|
``RequestContext`` will contain ``MEDIA_URL``, providing the
|
||||||
|
value of the `MEDIA_URL setting`_.
|
||||||
|
|
||||||
|
.. _MEDIA_URL setting: ../settings/#media-url
|
||||||
|
|
||||||
django.core.context_processors.request
|
django.core.context_processors.request
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue