Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14693, #14709 -- Backwards incompatible change to rectify the …

…confusion around the STATICFILES_URL and STATICFILES_ROOT settings.

  * Two new global settings that will be used by -- **but are not limited to** -- the staticfiles app: STATIC_ROOT and STATIC_URL.

  * Moving the 'django.contrib.staticfiles.templatetags.staticfiles' template tag to the core ('django.templatetags.static') and renaming it to 'get_static_prefix'.

  * Moving the context processor 'django.contrib.staticfiles.context_processors.staticfiles' to the core ('django.core.context_processors.static') and renaming it to 'static'.

  * Paths in media definitions will use STATIC_URL as the prefix if the value is not None, and falls back to the previously used MEDIA_URL.

Thanks again to the community for constructive criticism and Carl and Russ for sanity-inducing discussions on IRC.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14592 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 33d8fcde8a317184a627492f008a4eab9333ed88 1 parent 9b45f6c
Jannis Leidel authored November 17, 2010

Showing 31 changed files with 908 additions and 329 deletions. Show diff stats Hide diff stats

  1. 22  django/conf/global_settings.py
  2. 12  django/conf/project_template/settings.py
  3. 10  django/contrib/admin/templatetags/adminmedia.py
  4. 6  django/contrib/staticfiles/context_processors.py
  5. 36  django/contrib/staticfiles/handlers.py
  6. 4  django/contrib/staticfiles/management/commands/collectstatic.py
  7. 2  django/contrib/staticfiles/management/commands/runserver.py
  8. 15  django/contrib/staticfiles/storage.py
  9. 43  django/contrib/staticfiles/templatetags/staticfiles.py
  10. 11  django/contrib/staticfiles/urls.py
  11. 16  django/contrib/staticfiles/utils.py
  12. 7  django/core/context_processors.py
  13. 28  django/core/servers/basehttp.py
  14. 20  django/forms/widgets.py
  15. 84  django/templatetags/static.py
  16. 4  django/views/static.py
  17. 60  docs/howto/static-files.txt
  18. 2  docs/man/django-admin.1
  19. 122  docs/ref/contrib/staticfiles.txt
  20. 29  docs/ref/django-admin.txt
  21. 60  docs/ref/settings.txt
  22. 13  docs/ref/templates/api.txt
  23. 6  docs/releases/1.3-alpha-1.txt
  24. 45  docs/releases/1.3-alpha-2.txt
  25. 2  docs/releases/1.3.txt
  26. 1  docs/releases/index.txt
  27. 41  docs/topics/forms/media.txt
  28. 0  staticfiles/templatetags/__init__.py b/django/contrib/staticfiles/templatetags/__init__.py
  29. 460  tests/regressiontests/forms/tests/media.py
  30. 50  tests/regressiontests/staticfiles_tests/tests.py
  31. 26  tests/regressiontests/templates/tests.py
22  django/conf/global_settings.py
@@ -195,9 +195,9 @@
195 195
     'django.core.context_processors.debug',
196 196
     'django.core.context_processors.i18n',
197 197
     'django.core.context_processors.media',
  198
+    'django.core.context_processors.static',
198 199
 #    'django.core.context_processors.request',
199 200
     'django.contrib.messages.context_processors.messages',
200  
-    'django.contrib.staticfiles.context_processors.staticfiles',
201 201
 )
202 202
 
203 203
 # Output to use in template system for invalid (e.g. misspelled) variables.
@@ -256,13 +256,21 @@
256 256
 DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
257 257
 
258 258
 # Absolute filesystem path to the directory that will hold user-uploaded files.
259  
-# Example: "/home/media/media.lawrence.com/"
  259
+# Example: "/home/media/media.lawrence.com/media/"
260 260
 MEDIA_ROOT = ''
261 261
 
262 262
 # URL that handles the media served from MEDIA_ROOT.
263  
-# Example: "http://media.lawrence.com"
  263
+# Example: "http://media.lawrence.com/media/"
264 264
 MEDIA_URL = ''
265 265
 
  266
+# Absolute path to the directory that holds static files.
  267
+# Example: "/home/media/media.lawrence.com/static/"
  268
+STATIC_ROOT = ''
  269
+
  270
+# URL that handles the static files served from STATIC_ROOT.
  271
+# Example: "http://media.lawrence.com/static/"
  272
+STATIC_URL = None
  273
+
266 274
 # List of upload handler classes to be applied in order.
267 275
 FILE_UPLOAD_HANDLERS = (
268 276
     'django.core.files.uploadhandler.MemoryFileUploadHandler',
@@ -552,14 +560,6 @@
552 560
 # STATICFILES #
553 561
 ###############
554 562
 
555  
-# Absolute path to the directory that holds media.
556  
-# Example: "/home/media/media.lawrence.com/static/"
557  
-STATICFILES_ROOT = ''
558  
-
559  
-# URL that handles the static files served from STATICFILES_ROOT.
560  
-# Example: "http://media.lawrence.com/static/"
561  
-STATICFILES_URL = '/static/'
562  
-
563 563
 # A list of locations of additional static files
564 564
 STATICFILES_DIRS = ()
565 565
 
12  django/conf/project_template/settings.py
@@ -49,16 +49,16 @@
49 49
 
50 50
 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
51 51
 # trailing slash if there is a path component (optional in other cases).
52  
-# Examples: "http://media.lawrence.com", "http://example.com/media/"
  52
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
53 53
 MEDIA_URL = ''
54 54
 
55  
-# Absolute path to the directory that holds media.
  55
+# Absolute path to the directory that holds static files.
56 56
 # Example: "/home/media/media.lawrence.com/static/"
57  
-STATICFILES_ROOT = ''
  57
+STATIC_ROOT = ''
58 58
 
59  
-# URL that handles the static files served from STATICFILES_ROOT.
60  
-# Example: "http://static.lawrence.com/", "http://example.com/static/"
61  
-STATICFILES_URL = '/static/'
  59
+# URL that handles the static files served from STATIC_ROOT.
  60
+# Example: "http://media.lawrence.com/static/"
  61
+STATIC_URL = '/static/'
62 62
 
63 63
 # URL prefix for admin media -- CSS, JavaScript and images.
64 64
 # Make sure to use a trailing slash.
10  django/contrib/admin/templatetags/adminmedia.py
... ...
@@ -1,15 +1,11 @@
1 1
 from django.template import Library
2  
-from django.utils.encoding import iri_to_uri
  2
+from django.templatetags.static import PrefixNode
3 3
 
4 4
 register = Library()
5 5
 
  6
+@register.simple_tag
6 7
 def admin_media_prefix():
7 8
     """
8 9
     Returns the string contained in the setting ADMIN_MEDIA_PREFIX.
9 10
     """
10  
-    try:
11  
-        from django.conf import settings
12  
-    except ImportError:
13  
-        return ''
14  
-    return iri_to_uri(settings.ADMIN_MEDIA_PREFIX)
15  
-admin_media_prefix = register.simple_tag(admin_media_prefix)
  11
+    return PrefixNode.handle_simple("ADMIN_MEDIA_PREFIX")
6  django/contrib/staticfiles/context_processors.py
... ...
@@ -1,6 +0,0 @@
1  
-from django.conf import settings
2  
-
3  
-def staticfiles(request):
4  
-    return {
5  
-        'STATICFILES_URL': settings.STATICFILES_URL,
6  
-    }
36  django/contrib/staticfiles/handlers.py
@@ -10,46 +10,44 @@
10 10
 class StaticFilesHandler(WSGIHandler):
11 11
     """
12 12
     WSGI middleware that intercepts calls to the static files directory, as
13  
-    defined by the STATICFILES_URL setting, and serves those files.
  13
+    defined by the STATIC_URL setting, and serves those files.
14 14
     """
15  
-    def __init__(self, application, media_dir=None):
  15
+    def __init__(self, application, base_dir=None):
16 16
         self.application = application
17  
-        if media_dir:
18  
-            self.media_dir = media_dir
  17
+        if base_dir:
  18
+            self.base_dir = base_dir
19 19
         else:
20  
-            self.media_dir = self.get_media_dir()
21  
-        self.media_url = urlparse(self.get_media_url())
22  
-        if settings.DEBUG:
23  
-            utils.check_settings()
  20
+            self.base_dir = self.get_base_dir()
  21
+        self.base_url = urlparse(self.get_base_url())
24 22
         super(StaticFilesHandler, self).__init__()
25 23
 
26  
-    def get_media_dir(self):
27  
-        return settings.STATICFILES_ROOT
  24
+    def get_base_dir(self):
  25
+        return settings.STATIC_ROOT
28 26
 
29  
-    def get_media_url(self):
30  
-        return settings.STATICFILES_URL
  27
+    def get_base_url(self):
  28
+        if settings.DEBUG:
  29
+            utils.check_settings()
  30
+        return settings.STATIC_URL
31 31
 
32 32
     def _should_handle(self, path):
33 33
         """
34 34
         Checks if the path should be handled. Ignores the path if:
35 35
 
36  
-        * the host is provided as part of the media_url
  36
+        * the host is provided as part of the base_url
37 37
         * the request's path isn't under the media path (or equal)
38  
-        * settings.DEBUG isn't True
39 38
         """
40  
-        return (self.media_url[2] != path and
41  
-            path.startswith(self.media_url[2]) and not self.media_url[1])
  39
+        return (self.base_url[2] != path and
  40
+            path.startswith(self.base_url[2]) and not self.base_url[1])
42 41
 
43 42
     def file_path(self, url):
44 43
         """
45 44
         Returns the relative path to the media file on disk for the given URL.
46 45
 
47  
-        The passed URL is assumed to begin with ``media_url``.  If the
  46
+        The passed URL is assumed to begin with ``base_url``.  If the
48 47
         resultant file path is outside the media directory, then a ValueError
49 48
         is raised.
50 49
         """
51  
-        # Remove ``media_url``.
52  
-        relative_url = url[len(self.media_url[2]):]
  50
+        relative_url = url[len(self.base_url[2]):]
53 51
         return urllib.url2pathname(relative_url)
54 52
 
55 53
     def serve(self, request):
4  django/contrib/staticfiles/management/commands/collectstatic.py
@@ -12,7 +12,7 @@
12 12
 class Command(NoArgsCommand):
13 13
     """
14 14
     Command that allows to copy or symlink media files from different
15  
-    locations to the settings.STATICFILES_ROOT.
  15
+    locations to the settings.STATIC_ROOT.
16 16
     """
17 17
     option_list = NoArgsCommand.option_list + (
18 18
         make_option('--noinput', action='store_false', dest='interactive',
@@ -85,7 +85,7 @@ def handle_noargs(self, **options):
85 85
             self.stdout.write("\n%s static file%s %s to '%s'%s.\n"
86 86
                               % (actual_count, actual_count != 1 and 's' or '',
87 87
                                  symlink and 'symlinked' or 'copied',
88  
-                                 settings.STATICFILES_ROOT,
  88
+                                 settings.STATIC_ROOT,
89 89
                                  unmodified_count and ' (%s unmodified)'
90 90
                                  % unmodified_count or ''))
91 91
 
2  django/contrib/staticfiles/management/commands/runserver.py
@@ -8,7 +8,7 @@
8 8
 class Command(BaseRunserverCommand):
9 9
     option_list = BaseRunserverCommand.option_list + (
10 10
         make_option('--nostatic', action="store_false", dest='use_static_handler', default=True,
11  
-            help='Tells Django to NOT automatically serve static files at STATICFILES_URL.'),
  11
+            help='Tells Django to NOT automatically serve static files at STATIC_URL.'),
12 12
         make_option('--insecure', action="store_true", dest='insecure_serving', default=False,
13 13
             help='Allows serving static files even if DEBUG is False.'),
14 14
     )
15  django/contrib/staticfiles/storage.py
@@ -12,21 +12,22 @@ class StaticFilesStorage(FileSystemStorage):
12 12
     Standard file system storage for site media files.
13 13
     
14 14
     The defaults for ``location`` and ``base_url`` are
15  
-    ``STATICFILES_ROOT`` and ``STATICFILES_URL``.
  15
+    ``STATIC_ROOT`` and ``STATIC_URL``.
16 16
     """
17 17
     def __init__(self, location=None, base_url=None, *args, **kwargs):
18 18
         if location is None:
19  
-            location = settings.STATICFILES_ROOT
  19
+            location = settings.STATIC_ROOT
20 20
         if base_url is None:
21  
-            base_url = settings.STATICFILES_URL
  21
+            base_url = settings.STATIC_URL
22 22
         if not location:
23 23
             raise ImproperlyConfigured("You're using the staticfiles app "
24  
-                "without having set the STATICFILES_ROOT setting. Set it to "
  24
+                "without having set the STATIC_ROOT setting. Set it to "
25 25
                 "the absolute path of the directory that holds static media.")
26  
-        if not base_url:
  26
+        # check for None since we might use a root URL (``/``)
  27
+        if base_url is None:
27 28
             raise ImproperlyConfigured("You're using the staticfiles app "
28  
-                "without having set the STATICFILES_URL setting. Set it to "
29  
-                "URL that handles the files served from STATICFILES_ROOT.")
  29
+                "without having set the STATIC_URL setting. Set it to "
  30
+                "URL that handles the files served from STATIC_ROOT.")
30 31
         if settings.DEBUG:
31 32
             utils.check_settings()
32 33
         super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
43  django/contrib/staticfiles/templatetags/staticfiles.py
... ...
@@ -1,43 +0,0 @@
1  
-from django import template
2  
-from django.utils.encoding import iri_to_uri
3  
-
4  
-register = template.Library()
5  
-
6  
-class StaticFilesPrefixNode(template.Node):
7  
-
8  
-    def __init__(self, varname=None):
9  
-        self.varname = varname
10  
-
11  
-    def render(self, context):
12  
-        try:
13  
-            from django.conf import settings
14  
-        except ImportError:
15  
-            prefix = ''
16  
-        else:
17  
-            prefix = iri_to_uri(settings.STATICFILES_URL)
18  
-        if self.varname is None:
19  
-            return prefix
20  
-        context[self.varname] = prefix
21  
-        return ''
22  
-
23  
-@register.tag
24  
-def get_staticfiles_prefix(parser, token):
25  
-    """
26  
-    Populates a template variable with the prefix (settings.STATICFILES_URL).
27  
-
28  
-    Usage::
29  
-
30  
-        {% get_staticfiles_prefix [as varname] %}
31  
-
32  
-    Examples::
33  
-
34  
-        {% get_staticfiles_prefix %}
35  
-        {% get_staticfiles_prefix as staticfiles_prefix %}
36  
-
37  
-    """
38  
-    tokens = token.contents.split()
39  
-    if len(tokens) > 1 and tokens[1] != 'as':
40  
-        raise template.TemplateSyntaxError(
41  
-            "First argument in '%s' must be 'as'" % tokens[0])
42  
-    return StaticFilesPrefixNode(varname=(len(tokens) > 1 and tokens[2] or None))
43  
-
11  django/contrib/staticfiles/urls.py
@@ -18,15 +18,10 @@ def staticfiles_urlpatterns(prefix=None):
18 18
     if not settings.DEBUG:
19 19
         return []
20 20
     if prefix is None:
21  
-        prefix = settings.STATICFILES_URL
22  
-    if not prefix:
  21
+        prefix = settings.STATIC_URL
  22
+    if not prefix or '://' in prefix:
23 23
         raise ImproperlyConfigured(
24  
-            "The prefix for the 'staticfiles_urlpatterns' helper is empty. "
25  
-            "Make sure the STATICFILES_URL setting is set correctly.")
26  
-    if '://' in prefix:
27  
-        raise ImproperlyConfigured(
28  
-            "The STATICFILES_URL setting is a full URL, not a path and "
29  
-            "can't be used with the 'staticfiles_urlpatterns' helper.")
  24
+            "The prefix for the 'staticfiles_urlpatterns' helper is invalid.")
30 25
     if prefix.startswith("/"):
31 26
         prefix = prefix[1:]
32 27
     return patterns('',
16  django/contrib/staticfiles/utils.py
@@ -33,13 +33,13 @@ def is_ignored(path):
33 33
 
34 34
 def check_settings():
35 35
     """
36  
-    Checks if the MEDIA_(ROOT|URL) and STATICFILES_(ROOT|URL)
  36
+    Checks if the MEDIA_(ROOT|URL) and STATIC_(ROOT|URL)
37 37
     settings have the same value.
38 38
     """
39  
-    if settings.MEDIA_URL == settings.STATICFILES_URL:
40  
-        raise ImproperlyConfigured("The MEDIA_URL and STATICFILES_URL "
41  
-                                   "settings must have individual values")
42  
-    if ((settings.MEDIA_ROOT and settings.STATICFILES_ROOT) and
43  
-            (settings.MEDIA_ROOT == settings.STATICFILES_ROOT)):
44  
-        raise ImproperlyConfigured("The MEDIA_ROOT and STATICFILES_ROOT "
45  
-                                   "settings must have individual values")
  39
+    if settings.MEDIA_URL == settings.STATIC_URL:
  40
+        raise ImproperlyConfigured("The MEDIA_URL and STATIC_URL "
  41
+                                   "settings must have different values")
  42
+    if ((settings.MEDIA_ROOT and settings.STATIC_ROOT) and
  43
+            (settings.MEDIA_ROOT == settings.STATIC_ROOT)):
  44
+        raise ImproperlyConfigured("The MEDIA_ROOT and STATIC_ROOT "
  45
+                                   "settings must have different values")
7  django/core/context_processors.py
@@ -66,6 +66,13 @@ def i18n(request):
66 66
 
67 67
     return context_extras
68 68
 
  69
+def static(request):
  70
+    """
  71
+    Adds static-related context variables to the context.
  72
+
  73
+    """
  74
+    return {'STATIC_URL': settings.STATIC_URL}
  75
+
69 76
 def media(request):
70 77
     """
71 78
     Adds media-related context variables to the context.
28  django/core/servers/basehttp.py
@@ -17,8 +17,8 @@
17 17
 from django.core.management.color import color_style
18 18
 from django.utils.http import http_date
19 19
 from django.utils._os import safe_join
20  
-from django.contrib.staticfiles.handlers import StaticFilesHandler
21  
-from django.views import static
  20
+
  21
+from django.contrib.staticfiles import handlers, views as static
22 22
 
23 23
 __version__ = "0.1"
24 24
 __all__ = ['WSGIServer','WSGIRequestHandler']
@@ -635,19 +635,20 @@ def log_message(self, format, *args):
635 635
         sys.stderr.write(msg)
636 636
 
637 637
 
638  
-class AdminMediaHandler(StaticFilesHandler):
  638
+class AdminMediaHandler(handlers.StaticFilesHandler):
639 639
     """
640 640
     WSGI middleware that intercepts calls to the admin media directory, as
641 641
     defined by the ADMIN_MEDIA_PREFIX setting, and serves those images.
642 642
     Use this ONLY LOCALLY, for development! This hasn't been tested for
643 643
     security and is not super efficient.
644  
-    """
645 644
 
646  
-    def get_media_dir(self):
  645
+    This is pending for deprecation since 1.3.
  646
+    """
  647
+    def get_base_dir(self):
647 648
         import django
648 649
         return os.path.join(django.__path__[0], 'contrib', 'admin', 'media')
649 650
 
650  
-    def get_media_url(self):
  651
+    def get_base_url(self):
651 652
         from django.conf import settings
652 653
         return settings.ADMIN_MEDIA_PREFIX
653 654
 
@@ -655,14 +656,13 @@ def file_path(self, url):
655 656
         """
656 657
         Returns the path to the media file on disk for the given URL.
657 658
 
658  
-        The passed URL is assumed to begin with ``media_url``.  If the
659  
-        resultant file path is outside the media directory, then a ValueError
  659
+        The passed URL is assumed to begin with ``self.base_url``.  If the
  660
+        resulting file path is outside the media directory, then a ValueError
660 661
         is raised.
661 662
         """
662  
-        # Remove ``media_url``.
663  
-        relative_url = url[len(self.media_url[2]):]
  663
+        relative_url = url[len(self.base_url[2]):]
664 664
         relative_path = urllib.url2pathname(relative_url)
665  
-        return safe_join(self.media_dir, relative_path)
  665
+        return safe_join(self.base_dir, relative_path)
666 666
 
667 667
     def serve(self, request):
668 668
         document_root, path = os.path.split(self.file_path(request.path))
@@ -673,10 +673,10 @@ def _should_handle(self, path):
673 673
         """
674 674
         Checks if the path should be handled. Ignores the path if:
675 675
 
676  
-        * the host is provided as part of the media_url
677  
-        * the request's path isn't under the media path
  676
+        * the host is provided as part of the base_url
  677
+        * the request's path isn't under the base path
678 678
         """
679  
-        return path.startswith(self.media_url[2]) and not self.media_url[1]
  679
+        return path.startswith(self.base_url[2]) and not self.base_url[1]
680 680
 
681 681
 
682 682
 def run(addr, port, wsgi_handler):
20  django/forms/widgets.py
... ...
@@ -1,9 +1,13 @@
1 1
 """
2 2
 HTML Widget classes
3 3
 """
  4
+import datetime
  5
+from itertools import chain
  6
+import time
  7
+from urlparse import urljoin
  8
+from util import flatatt
4 9
 
5 10
 import django.utils.copycompat as copy
6  
-from itertools import chain
7 11
 from django.conf import settings
8 12
 from django.utils.datastructures import MultiValueDict, MergeDict
9 13
 from django.utils.html import escape, conditional_escape
@@ -11,10 +15,6 @@
11 15
 from django.utils.encoding import StrAndUnicode, force_unicode
12 16
 from django.utils.safestring import mark_safe
13 17
 from django.utils import datetime_safe, formats
14  
-import time
15  
-import datetime
16  
-from util import flatatt
17  
-from urlparse import urljoin
18 18
 
19 19
 __all__ = (
20 20
     'Media', 'MediaDefiningClass', 'Widget', 'TextInput', 'PasswordInput',
@@ -63,10 +63,16 @@ def render_css(self):
63 63
                     for path in self._css[medium]]
64 64
                 for medium in media])
65 65
 
66  
-    def absolute_path(self, path):
  66
+    def absolute_path(self, path, prefix=None):
67 67
         if path.startswith(u'http://') or path.startswith(u'https://') or path.startswith(u'/'):
68 68
             return path
69  
-        return urljoin(settings.MEDIA_URL,path)
  69
+        if prefix is None:
  70
+            if settings.STATIC_URL is None:
  71
+                 # backwards compatibility
  72
+                prefix = settings.MEDIA_URL
  73
+            else:
  74
+                prefix = settings.STATIC_URL
  75
+        return urljoin(prefix, path)
70 76
 
71 77
     def __getitem__(self, name):
72 78
         "Returns a Media object that only contains media of the given type"
84  django/templatetags/static.py
... ...
@@ -0,0 +1,84 @@
  1
+from django import template
  2
+from django.utils.encoding import iri_to_uri
  3
+
  4
+register = template.Library()
  5
+
  6
+class PrefixNode(template.Node):
  7
+
  8
+    def __repr__(self):
  9
+        return "<PrefixNode for %r>" % self.name
  10
+
  11
+    def __init__(self, varname=None, name=None):
  12
+        if name is None:
  13
+            raise template.TemplateSyntaxError(
  14
+                "Prefix nodes must be given a name to return.")
  15
+        self.varname = varname
  16
+        self.name = name
  17
+
  18
+    @classmethod
  19
+    def handle_token(cls, parser, token, name):
  20
+        """
  21
+        Class method to parse prefix node and return a Node.
  22
+        """
  23
+        tokens = token.contents.split()
  24
+        if len(tokens) > 1 and tokens[1] != 'as':
  25
+            raise template.TemplateSyntaxError(
  26
+                "First argument in '%s' must be 'as'" % tokens[0])
  27
+        if len(tokens) > 1:
  28
+            varname = tokens[2]
  29
+        else:
  30
+            varname = None
  31
+        return cls(varname, name)
  32
+
  33
+    @classmethod
  34
+    def handle_simple(cls, name):
  35
+        try:
  36
+            from django.conf import settings
  37
+        except ImportError:
  38
+            prefix = ''
  39
+        else:
  40
+            prefix = iri_to_uri(getattr(settings, name, ''))
  41
+        return prefix
  42
+
  43
+    def render(self, context):
  44
+        prefix = self.handle_simple(self.name)
  45
+        if self.varname is None:
  46
+            return prefix
  47
+        context[self.varname] = prefix
  48
+        return ''
  49
+
  50
+@register.tag
  51
+def get_static_prefix(parser, token):
  52
+    """
  53
+    Populates a template variable with the static prefix,
  54
+    ``settings.STATIC_URL``.
  55
+
  56
+    Usage::
  57
+
  58
+        {% get_static_prefix [as varname] %}
  59
+
  60
+    Examples::
  61
+
  62
+        {% get_static_prefix %}
  63
+        {% get_static_prefix as static_prefix %}
  64
+
  65
+    """
  66
+    return PrefixNode.handle_token(parser, token, "STATIC_URL")
  67
+
  68
+@register.tag
  69
+def get_media_prefix(parser, token):
  70
+    """
  71
+    Populates a template variable with the static prefix,
  72
+    ``settings.MEDIA_URL``.
  73
+
  74
+    Usage::
  75
+
  76
+        {% get_media_prefix [as varname] %}
  77
+
  78
+    Examples::
  79
+
  80
+        {% get_media_prefix %}
  81
+        {% get_media_prefix as media_prefix %}
  82
+
  83
+    """
  84
+    return PrefixNode.handle_token(parser, token, "MEDIA_URL")
4  django/views/static.py
@@ -17,8 +17,8 @@
17 17
 from django.template import Template, Context, TemplateDoesNotExist
18 18
 from django.utils.http import http_date
19 19
 
20  
-from django.contrib.staticfiles.views import \
21  
-    directory_index, was_modified_since, serve as staticfiles_serve
  20
+from django.contrib.staticfiles.views import (directory_index,
  21
+    was_modified_since, serve as staticfiles_serve)
22 22
 
23 23
 
24 24
 def serve(request, path, document_root=None, show_indexes=False, insecure=False):
60  docs/howto/static-files.txt
@@ -50,12 +50,12 @@ Here's the basic usage in a nutshell:
50 50
        First, you'll need to make sure that ``django.contrib.staticfiles`` is in
51 51
        your :setting:`INSTALLED_APPS`.
52 52
 
53  
-       Next, you'll need to edit :setting:`STATICFILES_ROOT` to point to where
  53
+       Next, you'll need to edit :setting:`STATIC_ROOT` to point to where
54 54
        you'd like your static media stored. For example::
55 55
 
56  
-            STATICFILES_ROOT = "/home/jacob/projects/mysite.com/static_media"
  56
+            STATIC_ROOT = "/home/jacob/projects/mysite.com/static_media"
57 57
 
58  
-       You may also want to set the :setting:`STATICFILES_URL` setting at this
  58
+       You may also want to set the :setting:`STATIC_URL` setting at this
59 59
        time, though the default value (of ``/static/``) is perfect for local
60 60
        development.
61 61
 
@@ -69,7 +69,7 @@ Here's the basic usage in a nutshell:
69 69
             ./manage.py collectstatic
70 70
 
71 71
        This'll churn through your static file storage and move them into the
72  
-       directory given by :setting:`STATICFILES_ROOT`. (This is not necessary
  72
+       directory given by :setting:`STATIC_ROOT`. (This is not necessary
73 73
        in local development if you are using :djadmin:`runserver` or adding
74 74
        ``staticfiles_urlpatterns`` to your URLconf; see below).
75 75
 
@@ -78,7 +78,7 @@ Here's the basic usage in a nutshell:
78 78
        If you're using the built-in development server (the
79 79
        :djadmin:`runserver` management command) and have the :setting:`DEBUG`
80 80
        setting set to ``True``, your staticfiles will automatically be served
81  
-       from :setting:`STATICFILES_URL` in development.
  81
+       from :setting:`STATIC_URL` in development.
82 82
 
83 83
        If you are using some other server for local development, you can
84 84
        quickly serve static media locally by adding::
@@ -98,7 +98,7 @@ Here's the basic usage in a nutshell:
98 98
 
99 99
           .. code-block:: html+django
100 100
 
101  
-               <img src="{{ STATICFILES_URL }}images/hi.jpg />
  101
+               <img src="{{ STATIC_URL }}images/hi.jpg />
102 102
 
103 103
        See :ref:`staticfiles-in-templates` for more details, including an
104 104
        alternate method (using a template tag).
@@ -115,7 +115,7 @@ the framework see :doc:`the staticfiles reference </ref/contrib/staticfiles>`.
115 115
    app is to make it easier to keep static files separate from user-uploaded
116 116
    files. For this reason, you will probably want to make your
117 117
    :setting:`MEDIA_ROOT` and :setting:`MEDIA_URL` different from your
118  
-   :setting:`STATICFILES_ROOT` and :setting:`STATICFILES_URL`. You will need to
  118
+   :setting:`STATIC_ROOT` and :setting:`STATIC_URL`. You will need to
119 119
    arrange for serving of files in :setting:`MEDIA_ROOT` yourself;
120 120
    ``staticfiles`` does not deal with user-uploaded media at all.
121 121
 
@@ -136,7 +136,7 @@ development, and it makes it *very* hard to change where you've deployed your
136 136
 media. If, for example, you wanted to switch to using a content delivery network
137 137
 (CDN), then you'd need to change more or less every single template.
138 138
 
139  
-A far better way is to use the value of the :setting:`STATICFILES_URL` setting
  139
+A far better way is to use the value of the :setting:`STATIC_URL` setting
140 140
 directly in your templates. This means that a switch of media servers only
141 141
 requires changing that single value. Much better!
142 142
 
@@ -147,7 +147,7 @@ With a context processor
147 147
 ------------------------
148 148
 
149 149
 The included context processor is the easy way. Simply make sure
150  
-``'django.contrib.staticfiles.context_processors.staticfiles'`` is in your
  150
+``'django.core.context_processors.static'`` is in your
151 151
 :setting:`TEMPLATE_CONTEXT_PROCESSORS`. It's there by default, and if you're
152 152
 editing that setting by hand it should look something like::
153 153
 
@@ -155,18 +155,18 @@ editing that setting by hand it should look something like::
155 155
         'django.core.context_processors.debug',
156 156
         'django.core.context_processors.i18n',
157 157
         'django.core.context_processors.media',
  158
+        'django.core.context_processors.static',
158 159
         'django.contrib.auth.context_processors.auth',
159 160
         'django.contrib.messages.context_processors.messages',
160  
-        'django.contrib.staticfiles.context_processors.staticfiles',
161 161
     )
162 162
 
163  
-Once that's done, you can refer to :setting:`STATICFILES_URL` in your templates:
  163
+Once that's done, you can refer to :setting:`STATIC_URL` in your templates:
164 164
 
165 165
 .. code-block:: html+django
166 166
 
167  
-     <img src="{{ STATICFILES_URL }}images/hi.jpg />
  167
+     <img src="{{ STATIC_URL }}images/hi.jpg />
168 168
 
169  
-If ``{{ STATICFILES_URL }}`` isn't working in your template, you're probably not
  169
+If ``{{ STATIC_URL }}`` isn't working in your template, you're probably not
170 170
 using :class:`~django.template.RequestContext` when rendering the template.
171 171
 
172 172
 As a brief refresher, context processors add variables into the contexts of
@@ -180,23 +180,23 @@ To see how that works, and to read more details, check out
180 180
 With a template tag
181 181
 -------------------
182 182
 
183  
-The second option is the :ttag:`get_staticfiles_prefix` template tag. You can
  183
+The second option is the :ttag:`get_static_prefix` template tag. You can
184 184
 use this if you're not using :class:`~django.template.RequestContext`, or if you
185  
-need more control over exactly where and how :setting:`STATICFILES_URL` is
  185
+need more control over exactly where and how :setting:`STATIC_URL` is
186 186
 injected into the template. Here's an example:
187 187
 
188 188
 .. code-block:: html+django
189 189
 
190  
-    {% load staticfiles %}
191  
-    <img src="{% get_staticfiles_prefix %}images/hi.jpg" />
  190
+    {% load static %}
  191
+    <img src="{% get_static_prefix %}images/hi.jpg" />
192 192
 
193 193
 There's also a second form you can use to avoid extra processing if you need the
194 194
 value multiple times:
195 195
 
196 196
 .. code-block:: html+django
197 197
 
198  
-    {% load staticfiles %}
199  
-    {% get_staticfiles_prefix as STATIC_PREFIX %}
  198
+    {% load static %}
  199
+    {% get_static_prefix as STATIC_PREFIX %}
200 200
 
201 201
     <img src="{{ STATIC_PREFIX }}images/hi.jpg" />
202 202
     <img src="{{ STATIC_PREFIX }}images/hi2.jpg" />
@@ -213,7 +213,7 @@ Thus, the ``staticfiles`` app ships with a quick and dirty helper view that you
213 213
 can use to serve files locally in development.
214 214
 
215 215
 This view is automatically enabled and will serve your static files at
216  
-:setting:`STATICFILES_URL` when you use the built-in :djadmin:`runserver`.
  216
+:setting:`STATIC_URL` when you use the built-in :djadmin:`runserver`.
217 217
 
218 218
 To enable this view if you are using some other server for local development,
219 219
 you'll add a couple of lines to your URLconf. The first line goes at the top of
@@ -225,11 +225,11 @@ the file, and the last line at the bottom::
225 225
 
226 226
     urlpatterns += staticfiles_urlpatterns()
227 227
 
228  
-This will inspect your :setting:`STATICFILES_URL` and
229  
-:setting:`STATICFILES_ROOT` settings and wire up the view to serve static media
  228
+This will inspect your :setting:`STATIC_URL` and
  229
+:setting:`STATIC_ROOT` settings and wire up the view to serve static media
230 230
 accordingly. Don't forget to set the :setting:`STATICFILES_DIRS` setting
231 231
 appropriately to let ``django.contrib.staticfiles`` know where to look for
232  
-files.
  232
+(additional) files.
233 233
 
234 234
 .. warning::
235 235
 
@@ -239,6 +239,9 @@ files.
239 239
     **insecure**. This is only intended for local development, and should
240 240
     **never be used in production**.
241 241
 
  242
+    Additionally, your :setting:`STATIC_URL` setting can't be either empty
  243
+    or a full URL such as ``http://static.example.com/``.
  244
+
242 245
 For a few more details, including an alternate method of enabling this view,
243 246
 see :ref:`staticfiles-development-view`.
244 247
 
@@ -249,7 +252,7 @@ Serving static files in production
249 252
 
250 253
 The basic outline of putting static files into production is simple: run the
251 254
 :djadmin:`collectstatic` command when static media changes, then arrange for the
252  
-collected media directory (:setting:`STATICFILES_ROOT`) to be moved to the media
  255
+collected media directory (:setting:`STATIC_ROOT`) to be moved to the media
253 256
 server and served.
254 257
 
255 258
 Of course, as with all deployment tasks, the devil's in the details. Every
@@ -264,8 +267,8 @@ app, the basic outline gets modified to look something like:
264 267
 
265 268
     * Push your code up to the deployment server.
266 269
     * On the server, run :djadmin:`collectstatic` to move all the media into
267  
-      :setting:`STATICFILES_ROOT`.
268  
-    * Point your web server at :setting:`STATICFILES_ROOT`. For example, here's
  270
+      :setting:`STATIC_ROOT`.
  271
+    * Point your web server at :setting:`STATIC_ROOT`. For example, here's
269 272
       :ref:`how to do this under Apache and mod_wsgi <serving-media-files>`.
270 273
 
271 274
 You'll probably want to automate this process, especially if you've got multiple
@@ -322,7 +325,7 @@ Since your media server won't be running Django, you'll need to modify the
322 325
 deployment strategy to look something like:
323 326
 
324 327
     * When your media changes, run :djadmin:`collectstatic` locally.
325  
-    * Push your local :setting:`STATICFILES_ROOT` up to the media server
  328
+    * Push your local :setting:`STATIC_ROOT` up to the media server
326 329
       into the directory that's being served. ``rsync`` is a good
327 330
       choice for this step since it only needs to transfer the
328 331
       bits of static media that have changed.
@@ -403,9 +406,6 @@ you'll need to make a few changes:
403 406
     * The management commands ``build_static`` and ``resolve_static`` are now
404 407
       called :djadmin:`collectstatic` and :djadmin:`findstatic`.
405 408
 
406  
-    * The settings ``STATIC_URL`` and ``STATIC_ROOT`` were renamed to
407  
-      :setting:`STATICFILES_URL` and :setting:`STATICFILES_ROOT`.
408  
-
409 409
     * The settings ``STATICFILES_PREPEND_LABEL_APPS``,
410 410
       ``STATICFILES_MEDIA_DIRNAMES`` and ``STATICFILES_EXCLUDED_APPS`` were
411 411
       removed.
2  docs/man/django-admin.1
@@ -165,7 +165,7 @@ Do not prompt the user for input.
165 165
 Disable the development server's auto\-reloader.
166 166
 .TP
167 167
 .I \-\-nostatic
168  
-Disable automatic serving of static files from STATICFILES_URL.
  168
+Disable automatic serving of static files from STATIC_URL.
169 169
 .TP
170 170
 .I \-\-insecure
171 171
 Enables serving of static files even if DEBUG is False.
122  docs/ref/contrib/staticfiles.txt
@@ -23,48 +23,11 @@ Settings
23 23
 
24 24
 .. highlight:: python
25 25
 
26  
-The following settings control the behavior of the staticfiles app. Only
27  
-:setting:`STATICFILES_ROOT` is required, but you'll probably also need to
28  
-configure :setting:`STATICFILES_URL` as well.
29  
-
30  
-.. setting:: STATICFILES_ROOT
31  
-
32  
-STATICFILES_ROOT
33  
-----------------
34  
-
35  
-Default: ``''`` (Empty string)
36  
-
37  
-The absolute path to the directory that the :djadmin:`collectstatic` management
38  
-command will collect static files into, for serving from
39  
-:setting:`STATICFILES_URL`::
40  
-
41  
-   STATICFILES_ROOT = "/home/example.com/static/"
42  
-
43  
-This is a **required setting** unless you've overridden
44  
-:setting:`STATICFILES_STORAGE` and are using a custom storage backend.
45  
-
46  
-This is not a place to store your static files permanently under version
47  
-control; you should do that in directories that will be found by your
48  
-:setting:`STATICFILES_FINDERS` (by default, per-app ``static/`` subdirectories,
49  
-and any directories you include in :setting:`STATICFILES_DIRS`). Files from
50  
-those locations will be collected into :setting:`STATICFILES_ROOT`.
51  
-
52  
-.. setting:: STATICFILES_URL
53  
-
54  
-STATICFILES_URL
55  
----------------
56  
-
57  
-Default: ``'/static/'``
58  
-
59  
-The URL that handles the files served from :setting:`STATICFILES_ROOT`, e.g.::
60  
-
61  
-    STATICFILES_URL = '/site_media/static/'
62  
-
63  
-... or perhaps::
64  
-
65  
-    STATICFILES_URL = 'http://static.example.com/'
  26
+.. note::
66 27
 
67  
-This should **always** have a trailing slash.
  28
+    The following settings control the behavior of the staticfiles app.
  29
+    Configuring the global settings :setting:`STATIC_ROOT` and
  30
+    :setting:`STATIC_URL` is **required**.
68 31
 
69 32
 .. setting:: STATICFILES_DIRS
70 33
 
@@ -98,7 +61,7 @@ tuples, e.g.::
98 61
 
99 62
 With this configuration, the :djadmin:`collectstatic` management command would
100 63
 for example collect the stats files in a ``'downloads'`` directory. So
101  
-assuming you have :setting:`STATICFILES_URL` set ``'/static/'``, this would
  64
+assuming you have :setting:`STATIC_URL` set ``'/static/'``, this would
102 65
 allow you to refer to the file ``'/opt/webfiles/stats/polls_20101022.tar.gz'``
103 66
 with ``'/static/downloads/polls_20101022.tar.gz'`` in your templates.
104 67
 
@@ -153,14 +116,14 @@ Management Commands
153 116
 
154 117
 .. highlight:: console
155 118
 
156  
-``django.contrib.staticfiles`` exposes two management commands.
  119
+``django.contrib.staticfiles`` exposes three management commands.
157 120
 
158 121
 collectstatic
159 122
 -------------
160 123
 
161 124
 .. django-admin:: collectstatic
162 125
 
163  
-Collects the static files into :setting:`STATICFILES_ROOT`.
  126
+Collects the static files into :setting:`STATIC_ROOT`.
164 127
 
165 128
 Duplicate file names are by default resolved in a similar way to how template
166 129
 resolution works: the file that is first found in one of the specified
@@ -218,44 +181,76 @@ for each relative path, use the ``--first`` option::
218 181
 This is a debugging aid; it'll show you exactly which static file will be
219 182
 collected for a given path.
220 183
 
  184
+runserver
  185
+---------
  186
+
  187
+Overrides the core :djadmin:`runserver` command if the ``staticfiles`` app
  188
+is :setting:`installed<INSTALLED_APPS>` and adds automatic serving of static
  189
+files and the following new options.
  190
+
  191
+.. django-admin-option:: --nostatic
  192
+
  193
+Use the ``--nostatic`` option to disable serving of static files with the
  194
+:doc:`staticfiles </ref/contrib/staticfiles>` app entirely. This option is
  195
+only available if the :doc:`staticfiles </ref/contrib/staticfiles>` app is
  196
+in your project's :setting:`INSTALLED_APPS` setting.
  197
+
  198
+Example usage::
  199
+
  200
+    django-admin.py runserver --nostatic
  201
+
  202
+.. django-admin-option:: --insecure
  203
+
  204
+Use the ``--insecure`` option to force serving of static files with the
  205
+:doc:`staticfiles </ref/contrib/staticfiles>` app even if the :setting:`DEBUG`
  206
+setting is ``False``. By using this you acknowledge the fact that it's
  207
+**grossly inefficient** and probably **insecure**. This is only intended for
  208
+local development, should **never be used in production** and is only
  209
+available if the :doc:`staticfiles </ref/contrib/staticfiles>` app is
  210
+in your project's :setting:`INSTALLED_APPS` setting.
  211
+
  212
+Example usage::
  213
+
  214
+    django-admin.py runserver --insecure
  215
+
221 216
 .. currentmodule:: None
222 217
 
223 218
 Other Helpers
224 219
 =============
225 220
 
226  
-The ``staticfiles`` context processor
227  
--------------------------------------
  221
+The ``static`` context processor
  222
+--------------------------------
228 223
 
229  
-.. function:: django.contrib.staticfiles.context_processors.staticfiles
  224
+.. function:: django.core.context_processors.static
230 225
 
231  
-This context processor adds the :setting:`STATICFILES_URL` into each template
232  
-context as the variable ``{{ STATICFILES_URL }}``. To use it, make sure that
233  
-``'django.contrib.staticfiles.context_processors.staticfiles'`` appears
234  
-somewhere in your :setting:`TEMPLATE_CONTEXT_PROCESSORS` setting.
  226
+This context processor adds the :setting:`STATIC_URL` into each template
  227
+context as the variable ``{{ STATIC_URL }}``. To use it, make sure that
  228
+``'django.core.context_processors.static'`` appears somewhere in your
  229
+:setting:`TEMPLATE_CONTEXT_PROCESSORS` setting.
235 230
 
236 231
 Remember, only templates rendered with :class:`~django.template.RequestContext`
237 232
 will have acces to the data provided by this (and any) context processor.
238 233
 
239  
-.. templatetag:: get_staticfiles_prefix
  234
+.. templatetag:: get_static_prefix
240 235
 
241  
-The ``get_staticfiles_prefix`` templatetag
242  
-==========================================
  236
+The ``get_static_prefix`` templatetag
  237
+=====================================
243 238
 
244 239
 .. highlight:: html+django
245 240
 
246 241
 If you're not using :class:`~django.template.RequestContext`, or if you need
247  
-more control over exactly where and how :setting:`STATICFILES_URL` is injected
248  
-into the template, you can use the :ttag:`get_staticfiles_prefix` template tag
  242
+more control over exactly where and how :setting:`STATIC_URL` is injected
  243
+into the template, you can use the :ttag:`get_static_prefix` template tag
249 244
 instead::
250 245
 
251  
-    {% load staticfiles %}
252  
-    <img src="{% get_staticfiles_prefix %}images/hi.jpg" />
  246
+    {% load static %}
  247
+    <img src="{% get_static_prefix %}images/hi.jpg" />
253 248
 
254 249
 There's also a second form you can use to avoid extra processing if you need
255 250
 the value multiple times::
256 251
 
257  
-    {% load staticfiles %}
258  
-    {% get_staticfiles_prefix as STATIC_PREFIX %}
  252
+    {% load static %}
  253
+    {% get_static_prefix as STATIC_PREFIX %}
259 254
 
260 255
     <img src="{{ STATIC_PREFIX }}images/hi.jpg" />
261 256
     <img src="{{ STATIC_PREFIX }}images/hi2.jpg" />
@@ -292,7 +287,7 @@ primary URL configuration::
292 287
        )
293 288
 
294 289
 Note, the begin of the pattern (``r'^static/'``) should be your
295  
-:setting:`STATICFILES_URL` setting.
  290
+:setting:`STATIC_URL` setting.
296 291
 
297 292
 Since this is a bit finicky, there's also a helper function that'll do this for you:
298 293
 
@@ -307,3 +302,8 @@ already defined pattern list. Use it like this::
307 302
 
308 303
    urlpatterns += staticfiles_urlpatterns()
309 304
 
  305
+.. warning::
  306
+
  307
+    This helper function will only work if :setting:`DEBUG` is ``True``
  308
+    and your :setting:`STATIC_URL` setting is neither empty nor a full
  309
+    URL such as ``http://static.example.com/``.
29  docs/ref/django-admin.txt
@@ -681,35 +681,6 @@ Example usage::
681 681
 
682 682
     django-admin.py runserver --noreload
683 683
 
684  
-.. django-admin-option:: --nostatic
685  
-
686  
-Use the ``--nostatic`` option to disable serving of static files with the
687  
-:doc:`staticfiles </ref/contrib/staticfiles>` app entirely. This option is
688  
-only available if the :doc:`staticfiles </ref/contrib/staticfiles>` app is
689  
-in your project's :setting:`INSTALLED_APPS` setting.
690  
-
691  
-Example usage::
692  
-
693  
-    django-admin.py runserver --nostatic
694  
-
695  
-.. django-admin-option:: --insecure
696  
-
697  
-Use the ``--insecure`` option to force serving of static files with the
698  
-:doc:`staticfiles </ref/contrib/staticfiles>` app even if the :setting:`DEBUG`
699  
-setting is ``False``. By using this you acknowledge the fact that it's
700  
-**grossly inefficient** and probably **insecure**. This is only intended for
701  
-local development, should **never be used in production** and is only
702  
-available if the :doc:`staticfiles </ref/contrib/staticfiles>` app is
703  
-in your project's :setting:`INSTALLED_APPS` setting.
704  
-
705  
-See the :doc:`reference documentation of the app </ref/contrib/staticfiles>`
706  
-for more details and learn how to :doc:`manage and deploy static files
707  
-</howto/static-files>` correctly.
708  
-
709  
-Example usage::
710  
-
711  
-    django-admin.py runserver --insecure
712  
-
713 684
 Examples of using different ports and addresses
714 685
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
715 686
 
60  docs/ref/settings.txt
@@ -53,10 +53,10 @@ Default: ``'/static/admin/'``
53 53
 
54 54
 The URL prefix for admin media -- CSS, JavaScript and images used by the Django
55 55
 administrative interface. Make sure to use a trailing slash, and to have this be
56  
-different from the :setting:``MEDIA_URL`` setting (since the same URL cannot be
  56
+different from the :setting:`MEDIA_URL` setting (since the same URL cannot be
57 57
 mapped onto two different sets of files). For integration with :doc:`staticfiles
58 58
 </ref/contrib/staticfiles>`, this should be the same as
59  
-:setting:`STATICFILES_URL` followed by ``'admin/'``.
  59
+:setting:`STATIC_URL` followed by ``'admin/'``.
60 60
 
61 61
 .. setting:: ADMINS
62 62
 
@@ -1122,12 +1122,12 @@ Default: ``''`` (Empty string)
1122 1122
 URL that handles the media served from :setting:`MEDIA_ROOT`, used
1123 1123
 for :doc:`managing stored files </topics/files>`.
1124 1124
 
1125  
-Example: ``"http://media.lawrence.com"``
  1125
+Example: ``"http://media.lawrence.com/"``
1126 1126
 
1127 1127
 Note that this should have a trailing slash if it has a path component.
1128 1128
 
1129  
- * Good: ``"http://www.example.com/static/"``
1130  
- * Bad: ``"http://www.example.com/static"``
  1129
+ * Good: ``"http://www.example.com/media/"``
  1130
+ * Bad: ``"http://www.example.com/media"``
1131 1131
 
1132 1132
 MESSAGE_LEVEL
1133 1133
 -------------
@@ -1486,6 +1486,49 @@ See :doc:`/ref/contrib/sites`.
1486 1486
 
1487 1487
 .. _site framework docs: ../sites/
1488 1488
 
  1489
+.. setting:: STATIC_ROOT
  1490
+
  1491
+STATIC_ROOT
  1492
+-----------
  1493
+
  1494
+Default: ``''`` (Empty string)
  1495
+
  1496
+The absolute path to the directory that contains static content.
  1497
+
  1498
+Example: ``"/home/example.com/static/"``
  1499
+
  1500
+When using the :djadmin:`collectstatic` management command of the optional,
  1501
+:doc:`staticfiles</ref/contrib/staticfiles>` app this will be used to collect
  1502
+static files into and served from :setting:`STATIC_URL`.
  1503
+
  1504
+In that case this is a **required setting**, unless you've overridden
  1505
+:setting:`STATICFILES_STORAGE` and are using a custom storage backend.
  1506
+
  1507
+This is not a place to store your static files permanently under version
  1508
+control; you should do that in directories that will be found by your
  1509
+:setting:`STATICFILES_FINDERS` (by default, per-app ``static/`` subdirectories,
  1510
+and any directories you include in :setting:`STATICFILES_DIRS`). Files from
  1511
+those locations will be collected into :setting:`STATIC_ROOT`.
  1512
+
  1513
+See :doc:`/ref/contrib/staticfiles` and :setting:`STATIC_URL`.
  1514
+
  1515
+.. setting:: STATIC_URL
  1516
+
  1517
+STATIC_URL
  1518
+----------
  1519
+
  1520
+Default: ``None``
  1521
+
  1522
+URL that handles the files served from :setting:`STATIC_ROOT`.
  1523
+
  1524
+Example: ``"/site_media/static/"`` or ``"http://static.example.com/"``
  1525
+
  1526
+If not ``None``, this will be used as the base path for
  1527
+:ref:`media definitions<form-media-paths>` and the
  1528
+:doc:`staticfiles app</ref/contrib/staticfiles>`.
  1529
+
  1530
+See :setting:`STATIC_ROOT`.
  1531
+
1489 1532
 .. setting:: TEMPLATE_CONTEXT_PROCESSORS
1490 1533
 
1491 1534
 TEMPLATE_CONTEXT_PROCESSORS
@@ -1496,7 +1539,8 @@ Default::
1496 1539
     ("django.contrib.auth.context_processors.auth",
1497 1540
     "django.core.context_processors.debug",
1498 1541
     "django.core.context_processors.i18n",
1499  
-    "django.contrib.staticfiles.context_processors.staticfiles",
  1542
+    "django.core.context_processors.media",
  1543
+    "django.core.context_processors.static",
1500 1544
     "django.contrib.messages.context_processors.messages")
1501 1545
 
1502 1546
 A tuple of callables that are used to populate the context in ``RequestContext``.
@@ -1513,6 +1557,10 @@ of items to be merged into the context.
1513 1557
     ``django.core.context_processors.auth`` to
1514 1558
     ``django.contrib.auth.context_processors.auth``.
1515 1559
 
  1560
+.. versionadded:: 1.3
  1561
+    The ``django.core.context_processors.static`` context processor
  1562
+    was added in this release.
  1563
+
1516 1564
 .. setting:: TEMPLATE_DEBUG
1517 1565
 
1518 1566
 TEMPLATE_DEBUG
13  docs/ref/templates/api.txt
@@ -312,8 +312,8 @@ and return a dictionary of items to be merged into the context. By default,
312 312
     "django.core.context_processors.debug",
313 313
     "django.core.context_processors.i18n",
314 314
     "django.core.context_processors.media",
315  
-    "django.contrib.messages.context_processors.messages",
316  
-    "django.contrib.staticfiles.context_processors.staticfiles")
  315
+    "django.core.context_processors.static",
  316
+    "django.contrib.messages.context_processors.messages")
317 317
 
318 318
 .. versionadded:: 1.2
319 319
    In addition to these, ``RequestContext`` always uses
@@ -435,6 +435,15 @@ If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
435 435
 ``RequestContext`` will contain a variable ``MEDIA_URL``, providing the
436 436
 value of the :setting:`MEDIA_URL` setting.
437 437