Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1278 -- Added a context processor that puts MEDIA_URL in the c…

…ontext, 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
  • Loading branch information...
commit d9f6470f2dd452280b5dd1108510f3f5dba0cb9c 1 parent c84ff15
Russell Keith-Magee authored May 29, 2007
1  django/conf/global_settings.py
@@ -144,6 +144,7 @@
144 144
     'django.core.context_processors.auth',
145 145
     'django.core.context_processors.debug',
146 146
     'django.core.context_processors.i18n',
  147
+    'django.core.context_processors.media',
147 148
 #    'django.core.context_processors.request',
148 149
 )
149 150
 
7  django/core/context_processors.py
@@ -42,6 +42,13 @@ def i18n(request):
42 42
 
43 43
     return context_extras
44 44
 
  45
+def media(request):
  46
+    """
  47
+    Adds media-related context variables to the context.
  48
+
  49
+    """
  50
+    return {'MEDIA_URL': settings.MEDIA_URL}
  51
+
45 52
 def request(request):
46 53
     return {'request': request}
47 54
 
3  docs/settings.txt
@@ -776,7 +776,8 @@ Default::
776 776
 
777 777
     ("django.core.context_processors.auth",
778 778
     "django.core.context_processors.debug",
779  
-    "django.core.context_processors.i18n")
  779
+    "django.core.context_processors.i18n",
  780
+    "django.core.context_processors.media")
780 781
 
781 782
 A tuple of callables that are used to populate the context in ``RequestContext``.
782 783
 These callables take a request object as their argument and return a dictionary
12  docs/templates_python.txt
@@ -294,7 +294,8 @@ return a dictionary of items to be merged into the context. By default,
294 294
 
295 295
     ("django.core.context_processors.auth",
296 296
     "django.core.context_processors.debug",
297  
-    "django.core.context_processors.i18n")
  297
+    "django.core.context_processors.i18n",
  298
+    "django.core.context_processors.media")
298 299
 
299 300
 Each processor is applied in order. That means, if one processor adds a
300 301
 variable to the context and a second processor adds a variable with the same
@@ -390,6 +391,15 @@ See the `internationalization docs`_ for more.
390 391
 .. _LANGUAGE_CODE setting: ../settings/#language-code
391 392
 .. _internationalization docs: ../i18n/
392 393
 
  394
+django.core.context_processors.media
  395
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  396
+
  397
+If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processors, every
  398
+``RequestContext`` will contain ``MEDIA_URL``,  providing the 
  399
+value of the `MEDIA_URL setting`_.
  400
+
  401
+.. _MEDIA_URL setting: ../settings/#media-url
  402
+
393 403
 django.core.context_processors.request
394 404
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
395 405
 

0 notes on commit d9f6470

Please sign in to comment.
Something went wrong with that request. Please try again.