Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.5.x] Fixed #19897 - Updated static files howto.

Thanks Jan Murre, Reinout van Rees and Wim Feijen,
plus Remco Wendt for reviewing.

Backport of i6c730da1f from master.
  • Loading branch information...
commit c3779d42142eb83eb8694177a12066261b3243aa 1 parent 1c42a3e
Tim Graham authored March 07, 2013
3  docs/howto/index.txt
@@ -21,7 +21,8 @@ you quickly accomplish common tasks.
21 21
    legacy-databases
22 22
    outputting-csv
23 23
    outputting-pdf
24  
-   static-files
  24
+   static-files/index
  25
+   static-files/deployment
25 26
 
26 27
 .. seealso::
27 28
 
159  docs/howto/static-files/deployment.txt
... ...
@@ -0,0 +1,159 @@
  1
+======================
  2
+Deploying static files
  3
+======================
  4
+
  5
+.. seealso::
  6
+
  7
+    For an introduction to the use of :mod:`django.contrib.staticfiles`, see
  8
+    :doc:`/howto/static-files/index`.
  9
+
  10
+.. _staticfiles-production:
  11
+
  12
+Serving static files in production
  13
+==================================
  14
+
  15
+The basic outline of putting static files into production is simple: run the
  16
+:djadmin:`collectstatic` command when static files change, then arrange for
  17
+the collected static files directory (:setting:`STATIC_ROOT`) to be moved to
  18
+the static file server and served. Depending on :setting:`STATICFILES_STORAGE`,
  19
+files may need to be moved to a new location manually or the :func:`post_process
  20
+<django.contrib.staticfiles.storage.StaticFilesStorage.post_process>` method
  21
+of the ``Storage`` class might take care of that.
  22
+
  23
+Of course, as with all deployment tasks, the devil's in the details. Every
  24
+production setup will be a bit different, so you'll need to adapt the basic
  25
+outline to fit your needs. Below are a few common patterns that might help.
  26
+
  27
+Serving the site and your static files from the same server
  28
+-----------------------------------------------------------
  29
+
  30
+If you want to serve your static files from the same server that's already
  31
+serving your site, the process may look something like:
  32
+
  33
+* Push your code up to the deployment server.
  34
+* On the server, run :djadmin:`collectstatic` to copy all the static files
  35
+  into :setting:`STATIC_ROOT`.
  36
+* Configure your web server to serve the files in :setting:`STATIC_ROOT`
  37
+  under the URL :setting:`STATIC_URL`. For example, here's
  38
+  :ref:`how to do this with Apache and mod_wsgi <serving-files>`.
  39
+
  40
+You'll probably want to automate this process, especially if you've got
  41
+multiple web servers. There's any number of ways to do this automation, but
  42
+one option that many Django developers enjoy is `Fabric
  43
+<http://fabfile.org/>`_.
  44
+
  45
+Below, and in the following sections, we'll show off a few example fabfiles
  46
+(i.e. Fabric scripts) that automate these file deployment options. The syntax
  47
+of a fabfile is fairly straightforward but won't be covered here; consult
  48
+`Fabric's documentation <http://docs.fabfile.org/>`_, for a complete
  49
+explanation of the syntax.
  50
+
  51
+So, a fabfile to deploy static files to a couple of web servers might look
  52
+something like::
  53
+
  54
+    from fabric.api import *
  55
+
  56
+    # Hosts to deploy onto
  57
+    env.hosts = ['www1.example.com', 'www2.example.com']
  58
+
  59
+    # Where your project code lives on the server
  60
+    env.project_root = '/home/www/myproject'
  61
+
  62
+    def deploy_static():
  63
+        with cd(env.project_root):
  64
+            run('./manage.py collectstatic -v0 --noinput')
  65
+
  66
+Serving static files from a dedicated server
  67
+--------------------------------------------
  68
+
  69
+Most larger Django sites use a separate Web server -- i.e., one that's not also
  70
+running Django -- for serving static files. This server often runs a different
  71
+type of web server -- faster but less full-featured. Some common choices are:
  72
+
  73
+* lighttpd_
  74
+* Nginx_
  75
+* TUX_
  76
+* Cherokee_
  77
+* A stripped-down version of Apache_
  78
+
  79
+.. _lighttpd: http://www.lighttpd.net/
  80
+.. _Nginx: http://wiki.nginx.org/Main
  81
+.. _TUX: http://en.wikipedia.org/wiki/TUX_web_server
  82
+.. _Apache: http://httpd.apache.org/
  83
+.. _Cherokee: http://www.cherokee-project.com/
  84
+
  85
+Configuring these servers is out of scope of this document; check each
  86
+server's respective documentation for instructions.
  87
+
  88
+Since your static file server won't be running Django, you'll need to modify
  89
+the deployment strategy to look something like:
  90
+
  91
+* When your static files change, run :djadmin:`collectstatic` locally.
  92
+
  93
+* Push your local :setting:`STATIC_ROOT` up to the static file server into the
  94
+  directory that's being served. `rsync <https://rsync.samba.org/>`_ is a
  95
+  common choice for this step since it only needs to transfer the bits of
  96
+  static files that have changed.
  97
+
  98
+Here's how this might look in a fabfile::
  99
+
  100
+    from fabric.api import *
  101
+    from fabric.contrib import project
  102
+
  103
+    # Where the static files get collected locally. Your STATIC_ROOT setting.
  104
+    env.local_static_root = '/tmp/static'
  105
+
  106
+    # Where the static files should go remotely
  107
+    env.remote_static_root = '/home/www/static.example.com'
  108
+
  109
+    @roles('static')
  110
+    def deploy_static():
  111
+        local('./manage.py collectstatic')
  112
+        project.rsync_project(
  113
+            remote_dir = env.remote_static_root,
  114
+            local_dir = env.local_static_root,
  115
+            delete = True
  116
+        )
  117
+
  118
+.. _staticfiles-from-cdn:
  119
+
  120
+Serving static files from a cloud service or CDN
  121
+------------------------------------------------
  122
+
  123
+Another common tactic is to serve static files from a cloud storage provider
  124
+like Amazon's S3 and/or a CDN (content delivery network). This lets you
  125
+ignore the problems of serving static files and can often make for
  126
+faster-loading webpages (especially when using a CDN).
  127
+
  128
+When using these services, the basic workflow would look a bit like the above,
  129
+except that instead of using ``rsync`` to transfer your static files to the
  130
+server you'd need to transfer the static files to the storage provider or CDN.
  131
+
  132
+There's any number of ways you might do this, but if the provider has an API a
  133
+:doc:`custom file storage backend </howto/custom-file-storage>` will make the
  134
+process incredibly simple. If you've written or are using a 3rd party custom
  135
+storage backend, you can tell :djadmin:`collectstatic` to use it by setting
  136
+:setting:`STATICFILES_STORAGE` to the storage engine.
  137
+
  138
+For example, if you've written an S3 storage backend in
  139
+``myproject.storage.S3Storage`` you could use it with::
  140
+
  141
+    STATICFILES_STORAGE = 'myproject.storage.S3Storage'
  142
+
  143
+Once that's done, all you have to do is run :djadmin:`collectstatic` and your
  144
+static files would be pushed through your storage package up to S3. If you
  145
+later needed to switch to a different storage provider, it could be as simple
  146
+as changing your :setting:`STATICFILES_STORAGE` setting.
  147
+
  148
+For details on how you'd write one of these backends, see
  149
+:doc:`/howto/custom-file-storage`. There are 3rd party apps available that
  150
+provide storage backends for many common file storage APIs. A good starting
  151
+point is the `overview at djangopackages.com
  152
+<https://www.djangopackages.com/grids/g/storage-backends/>`_.
  153
+
  154
+Learn more
  155
+==========
  156
+
  157
+For complete details on all the settings, commands, template tags, and other
  158
+pieces included in :mod:`django.contrib.staticfiles`, see :doc:`the
  159
+staticfiles reference </ref/contrib/staticfiles>`.
527  docs/howto/static-files/index.txt
... ...
@@ -1,314 +1,79 @@
1  
-=====================
2  
-Managing static files
3  
-=====================
4  
-
5  
-Django developers mostly concern themselves with the dynamic parts of web
6  
-applications -- the views and templates that render anew for each request. But
7  
-web applications have other parts: the static files (images, CSS,
8  
-Javascript, etc.) that are needed to render a complete web page.
9  
-
10  
-For small projects, this isn't a big deal, because you can just keep the
11  
-static files somewhere your web server can find it. However, in bigger
12  
-projects -- especially those comprised of multiple apps -- dealing with the
13  
-multiple sets of static files provided by each application starts to get
14  
-tricky.
15  
-
16  
-That's what ``django.contrib.staticfiles`` is for: it collects static files
17  
-from each of your applications (and any other places you specify) into a
18  
-single location that can easily be served in production.
19  
-
20  
-.. note::
21  
-
22  
-    If you've used the `django-staticfiles`_ third-party app before, then
23  
-    ``django.contrib.staticfiles`` will look very familiar. That's because
24  
-    they're essentially the same code: ``django.contrib.staticfiles`` started
25  
-    its life as `django-staticfiles`_ and was merged into Django 1.3.
26  
-
27  
-    If you're upgrading from ``django-staticfiles``, please see `Upgrading from
28  
-    django-staticfiles`_, below, for a few minor changes you'll need to make.
29  
-
30  
-.. _django-staticfiles: http://pypi.python.org/pypi/django-staticfiles/
  1
+===================================
  2
+Managing static files (CSS, images)
  3
+===================================
31 4
 
32  
-Using ``django.contrib.staticfiles``
33  
-====================================
  5
+Websites generally need to serve additional files such as images, JavaScript,
  6
+or CSS. In Django, we refer to these files as "static files".  Django provides
  7
+:mod:`django.contrib.staticfiles` to help you manage them.
34 8
 
35  
-Basic usage
36  
------------
  9
+This page describes how you can serve these static files.
37 10
 
38  
-1. Put your static files somewhere that ``staticfiles`` will find them.
  11
+Configuring static files
  12
+========================
39 13
 
40  
-   By default, this means within ``static/`` subdirectories of apps in your
  14
+1. Make sure that ``django.contrib.staticfiles`` is included in your
41 15
    :setting:`INSTALLED_APPS`.
42 16
 
43  
-   Your project will probably also have static assets that aren't tied to a
44  
-   particular app. The :setting:`STATICFILES_DIRS` setting is a tuple of
45  
-   filesystem directories to check when loading static files. It's a search
46  
-   path that is by default empty. See the :setting:`STATICFILES_DIRS` docs
47  
-   how to extend this list of additional paths.
  17
+2. In your settings file, define :setting:`STATIC_URL`, for example::
48 18
 
49  
-   Additionally, see the documentation for the :setting:`STATICFILES_FINDERS`
50  
-   setting for details on how ``staticfiles`` finds your files.
51  
-
52  
-2. Make sure that ``django.contrib.staticfiles`` is included in your
53  
-   :setting:`INSTALLED_APPS`.
  19
+      STATIC_URL = '/static/'
54 20
 
55  
-   For :ref:`local development<staticfiles-development>`, if you are using
56  
-   :ref:`runserver<staticfiles-runserver>` or adding
57  
-   :ref:`staticfiles_urlpatterns<staticfiles-development>` to your
58  
-   URLconf, you're done with the setup -- your static files will
59  
-   automatically be served at the default (for
60  
-   :djadmin:`newly created<startproject>` projects) :setting:`STATIC_URL`
61  
-   of ``/static/``.
  21
+3. In your templates, either hardcode the url like
  22
+   ``/static/my_app/myexample.jpg`` or, preferably, use the
  23
+   :ttag:`static<staticfiles-static>` template tag to build the URL for the given
  24
+   relative path by using the configured :setting:`STATICFILES_STORAGE` storage
  25
+   (this makes it much easier when you want to switch to a content delivery
  26
+   network (CDN) for serving static files).
62 27
 
63  
-3. You'll probably need to refer to these files in your templates. The
64  
-   easiest method is to use the included context processor which allows
65  
-   template code like:
  28
+   .. _staticfiles-in-templates:
66 29
 
67 30
    .. code-block:: html+django
68 31
 
69  
-       <img src="{{ STATIC_URL }}images/hi.jpg" alt="Hi!" />
70  
-
71  
-   See :ref:`staticfiles-in-templates` for more details, **including** an
72  
-   alternate method using a template tag.
73  
-
74  
-Deploying static files in a nutshell
75  
-------------------------------------
76  
-
77  
-When you're ready to move out of local development and deploy your project:
78  
-
79  
-1. Set the :setting:`STATIC_URL` setting to the public URL for your static
80  
-   files (in most cases, the default value of ``/static/`` is just fine).
81  
-
82  
-2. Set the :setting:`STATIC_ROOT` setting to point to the filesystem path
83  
-   you'd like your static files collected to when you use the
84  
-   :djadmin:`collectstatic` management command. For example::
85  
-
86  
-       STATIC_ROOT = "/home/jacob/projects/mysite.com/sitestatic"
87  
-
88  
-3. Run the :djadmin:`collectstatic` management command::
89  
-
90  
-       ./manage.py collectstatic
91  
-
92  
-   This'll churn through your static file storage and copy them into the
93  
-   directory given by :setting:`STATIC_ROOT`.
94  
-
95  
-4. Deploy those files by configuring your webserver of choice to serve the
96  
-   files in :setting:`STATIC_ROOT` at :setting:`STATIC_URL`.
97  
-
98  
-   :ref:`staticfiles-production` covers some common deployment strategies
99  
-   for static files.
100  
-
101  
-Those are the **basics**. For more details on common configuration options,
102  
-read on; for a detailed reference of the settings, commands, and other bits
103  
-included with the framework see
104  
-:doc:`the staticfiles reference </ref/contrib/staticfiles>`.
105  
-
106  
-.. note::
107  
-
108  
-   In previous versions of Django, it was common to place static assets in
109  
-   :setting:`MEDIA_ROOT` along with user-uploaded files, and serve them both
110  
-   at :setting:`MEDIA_URL`. Part of the purpose of introducing the
111  
-   ``staticfiles`` app is to make it easier to keep static files separate
112  
-   from user-uploaded files.
113  
-
114  
-   For this reason, you need to make your :setting:`MEDIA_ROOT` and
115  
-   :setting:`MEDIA_URL` different from your :setting:`STATIC_ROOT` and
116  
-   :setting:`STATIC_URL`. You will need to arrange for serving of files in
117  
-   :setting:`MEDIA_ROOT` yourself; ``staticfiles`` does not deal with
118  
-   user-uploaded files at all. You can, however, use
119  
-   :func:`django.views.static.serve` view for serving :setting:`MEDIA_ROOT`
120  
-   in development; see :ref:`staticfiles-other-directories`.
  32
+        {% load staticfiles %}
  33
+        <img src="{% static "my_app/myexample.jpg" %}" alt="My image"/>
121 34
 
122  
-.. _staticfiles-in-templates:
  35
+3. Store your static files in a folder called ``static`` in your app. For
  36
+   example ``my_app/static/my_app/myimage.jpg``.
123 37
 
124  
-Referring to static files in templates
125  
-======================================
  38
+Now, if you use ``./manage.py runserver``, all static files should be served
  39
+automatically at the :setting:`STATIC_URL` and be shown correctly.
126 40
 
127  
-At some point, you'll probably need to link to static files in your templates.
128  
-You could, of course, simply hardcode the path to you assets in the templates:
  41
+Your project will probably also have static assets that aren't tied to a
  42
+particular app. In addition to using a ``static/`` directory inside your apps,
  43
+you can define a list of directories (:setting:`STATICFILES_DIRS`) in your
  44
+settings file where Django will also look for static files. For example::
129 45
 
130  
-.. code-block:: html
131  
-
132  
-    <img src="http://static.example.com/static/myimage.jpg" alt="Sample image" />
133  
-
134  
-Of course, there are some serious problems with this: it doesn't work well in
135  
-development, and it makes it *very* hard to change where you've deployed your
136  
-static files. If, for example, you wanted to switch to using a content
137  
-delivery network (CDN), then you'd need to change more or less every single
138  
-template.
139  
-
140  
-A far better way is to use the value of the :setting:`STATIC_URL` setting
141  
-directly in your templates. This means that a switch of static files servers
142  
-only requires changing that single value. Much better!
143  
-
144  
-Django includes multiple built-in ways of using this setting in your
145  
-templates: a context processor and a template tag.
146  
-
147  
-With a context processor
148  
-------------------------
149  
-
150  
-The included context processor is the easy way. Simply make sure
151  
-``'django.core.context_processors.static'`` is in your
152  
-:setting:`TEMPLATE_CONTEXT_PROCESSORS`. It's there by default, and if you're
153  
-editing that setting by hand it should look something like::
154  
-
155  
-    TEMPLATE_CONTEXT_PROCESSORS = (
156  
-        'django.core.context_processors.debug',
157  
-        'django.core.context_processors.i18n',
158  
-        'django.core.context_processors.media',
159  
-        'django.core.context_processors.static',
160  
-        'django.contrib.auth.context_processors.auth',
161  
-        'django.contrib.messages.context_processors.messages',
  46
+    STATICFILES_DIRS = (
  47
+        os.path.join(BASE_DIR, "static"),
  48
+        '/var/www/static/',
162 49
     )
163 50
 
164  
-Once that's done, you can refer to :setting:`STATIC_URL` in your templates:
165  
-
166  
-.. code-block:: html+django
167  
-
168  
-     <img src="{{ STATIC_URL }}images/hi.jpg" alt="Hi!" />
169  
-
170  
-If ``{{ STATIC_URL }}`` isn't working in your template, you're probably not
171  
-using :class:`~django.template.RequestContext` when rendering the template.
172  
-
173  
-As a brief refresher, context processors add variables into the contexts of
174  
-every template. However, context processors require that you use
175  
-:class:`~django.template.RequestContext` when rendering templates. This happens
176  
-automatically if you're using a :doc:`generic view </ref/class-based-views/index>`,
177  
-but in views written by hand you'll need to explicitly use ``RequestContext``
178  
-To see how that works, and to read more details, check out
179  
-:ref:`subclassing-context-requestcontext`.
180  
-
181  
-Another option is the :ttag:`get_static_prefix` template tag that is part of
182  
-Django's core.
183  
-
184  
-With a template tag
185  
--------------------
186  
-
187  
-The more powerful tool is the :ttag:`static<staticfiles-static>` template
188  
-tag. It builds the URL for the given relative path by using the configured
189  
-:setting:`STATICFILES_STORAGE` storage.
190  
-
191  
-.. code-block:: html+django
192  
-
193  
-    {% load staticfiles %}
194  
-    <img src="{% static "images/hi.jpg" %}" alt="Hi!"/>
195  
-
196  
-It is also able to consume standard context variables, e.g. assuming a
197  
-``user_stylesheet`` variable is passed to the template:
198  
-
199  
-.. code-block:: html+django
200  
-
201  
-    {% load staticfiles %}
202  
-    <link rel="stylesheet" href="{% static user_stylesheet %}" type="text/css" media="screen" />
203  
-
204  
-.. note::
205  
-
206  
-    There is also a template tag named :ttag:`static` in Django's core set
207  
-    of :ref:`built in template tags<ref-templates-builtins-tags>` which has
208  
-    the same argument signature but only uses `urlparse.urljoin()`_ with the
209  
-    :setting:`STATIC_URL` setting and the given path. This has the
210  
-    disadvantage of not being able to easily switch the storage backend
211  
-    without changing the templates, so in doubt use the ``staticfiles``
212  
-    :ttag:`static<staticfiles-static>`
213  
-    template tag.
214  
-
215  
-.. _`urlparse.urljoin()`: http://docs.python.org/library/urlparse.html#urlparse.urljoin
216  
-
217  
-.. _staticfiles-development:
218  
-
219  
-Serving static files in development
220  
-===================================
221  
-
222  
-The static files tools are mostly designed to help with getting static files
223  
-successfully deployed into production. This usually means a separate,
224  
-dedicated static file server, which is a lot of overhead to mess with when
225  
-developing locally. Thus, the ``staticfiles`` app ships with a
226  
-**quick and dirty helper view** that you can use to serve files locally in
227  
-development.
228  
-
229  
-This view is automatically enabled and will serve your static files at
230  
-:setting:`STATIC_URL` when you use the built-in
231  
-:ref:`runserver<staticfiles-runserver>` management command.
232  
-
233  
-To enable this view if you are using some other server for local development,
234  
-you'll add a couple of lines to your URLconf. The first line goes at the top
235  
-of the file, and the last line at the bottom::
  51
+See the documentation for the :setting:`STATICFILES_FINDERS` setting for
  52
+details on how ``staticfiles`` finds your files.
236 53
 
237  
-    from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  54
+.. admonition:: Static file namespacing
238 55
 
239  
-    # ... the rest of your URLconf goes here ...
  56
+    Now we *might* be able to get away with putting our static files directly
  57
+    in ``my_app/static/`` (rather than creating another ``my_app``
  58
+    subdirectory), but it would actually be a bad idea. Django will use the
  59
+    last static file it finds whose name matches, and if you had a static file
  60
+    with the same name in a *different* application, Django would be unable to
  61
+    distinguish between them. We need to be able to point Django at the right
  62
+    one, and the easiest way to ensure this is by *namespacing* them. That is,
  63
+    by putting those static files inside *another* directory named for the
  64
+    application itself.
240 65
 
241  
-    urlpatterns += staticfiles_urlpatterns()
242 66
 
243  
-This will inspect your :setting:`STATIC_URL` setting and wire up the view
244  
-to serve static files accordingly. Don't forget to set the
245  
-:setting:`STATICFILES_DIRS` setting appropriately to let
246  
-``django.contrib.staticfiles`` know where to look for files additionally to
247  
-files in app directories.
  67
+Serving files uploaded by a user
  68
+================================
248 69
 
249  
-.. warning::
  70
+During development, you can serve user-uploaded media files from
  71
+:setting:`MEDIA_ROOT` using the :func:`django.contrib.staticfiles.views.serve`
  72
+view. This is not suitable for production use! For some common deployment
  73
+strategies, see :doc:`/howto/static-files/deployment`.
250 74
 
251  
-    This will only work if :setting:`DEBUG` is ``True``.
252  
-
253  
-    That's because this view is **grossly inefficient** and probably
254  
-    **insecure**. This is only intended for local development, and should
255  
-    **never be used in production**.
256  
-
257  
-    Additionally, when using ``staticfiles_urlpatterns`` your
258  
-    :setting:`STATIC_URL` setting can't be empty or a full URL, such as
259  
-    ``http://static.example.com/``.
260  
-
261  
-For a few more details on how the ``staticfiles`` can be used during
262  
-development, see :ref:`staticfiles-development-view`.
263  
-
264  
-.. _staticfiles-other-directories:
265  
-
266  
-Serving other directories
267  
--------------------------
268  
-
269  
-.. currentmodule:: django.views.static
270  
-.. function:: serve(request, path, document_root, show_indexes=False)
271  
-
272  
-There may be files other than your project's static assets that, for
273  
-convenience, you'd like to have Django serve for you in local development.
274  
-The :func:`~django.views.static.serve` view can be used to serve any directory
275  
-you give it. (Again, this view is **not** hardened for production
276  
-use, and should be used only as a development aid; you should serve these files
277  
-in production using a real front-end webserver).
278  
-
279  
-The most likely example is user-uploaded content in :setting:`MEDIA_ROOT`.
280  
-``staticfiles`` is intended for static assets and has no built-in handling
281  
-for user-uploaded files, but you can have Django serve your
282  
-:setting:`MEDIA_ROOT` by appending something like this to your URLconf::
283  
-
284  
-    from django.conf import settings
285  
-
286  
-    # ... the rest of your URLconf goes here ...
287  
-
288  
-    if settings.DEBUG:
289  
-        urlpatterns += patterns('',
290  
-            url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
291  
-                'document_root': settings.MEDIA_ROOT,
292  
-            }),
293  
-       )
294  
-
295  
-Note, the snippet assumes your :setting:`MEDIA_URL` has a value of
296  
-``'/media/'``. This will call the :func:`~django.views.static.serve` view,
297  
-passing in the path from the URLconf and the (required) ``document_root``
298  
-parameter.
299  
-
300  
-.. currentmodule:: django.conf.urls.static
301  
-.. function:: static(prefix, view='django.views.static.serve', **kwargs)
302  
-
303  
-Since it can become a bit cumbersome to define this URL pattern, Django
304  
-ships with a small URL helper function
305  
-:func:`~django.conf.urls.static.static` that takes as parameters the prefix
306  
-such as :setting:`MEDIA_URL` and a dotted path to a view, such as
307  
-``'django.views.static.serve'``. Any other function parameter will be
308  
-transparently passed to the view.
309  
-
310  
-An example for serving :setting:`MEDIA_URL` (``'/media/'``) during
311  
-development::
  75
+For example, if your :setting:`MEDIA_URL` is defined as '/media/', you can do
  76
+this by adding the following snippet to your urls.py::
312 77
 
313 78
     from django.conf import settings
314 79
     from django.conf.urls.static import static
@@ -319,190 +84,36 @@ development::
319 84
 
320 85
 .. note::
321 86
 
322  
-    This helper function will only be operational in debug mode and if
  87
+    This helper function works only in debug mode and only if
323 88
     the given prefix is local (e.g. ``/static/``) and not a URL (e.g.
324 89
     ``http://static.example.com/``).
325 90
 
326  
-.. _staticfiles-production:
327  
-
328  
-Serving static files in production
329  
-==================================
330  
-
331  
-The basic outline of putting static files into production is simple: run the
332  
-:djadmin:`collectstatic` command when static files change, then arrange for
333  
-the collected static files directory (:setting:`STATIC_ROOT`) to be moved to
334  
-the static file server and served.
335  
-
336  
-Of course, as with all deployment tasks, the devil's in the details. Every
337  
-production setup will be a bit different, so you'll need to adapt the basic
338  
-outline to fit your needs. Below are a few common patterns that might help.
339  
-
340  
-Serving the app and your static files from the same server
341  
-----------------------------------------------------------
342  
-
343  
-If you want to serve your static files from the same server that's already
344  
-serving your site, the basic outline gets modified to look something like:
345  
-
346  
-* Push your code up to the deployment server.
347  
-* On the server, run :djadmin:`collectstatic` to copy all the static files
348  
-  into :setting:`STATIC_ROOT`.
349  
-* Point your web server at :setting:`STATIC_ROOT`. For example, here's
350  
-  :ref:`how to do this under Apache and mod_wsgi <serving-files>`.
351  
-
352  
-You'll probably want to automate this process, especially if you've got
353  
-multiple web servers. There's any number of ways to do this automation, but
354  
-one option that many Django developers enjoy is `Fabric`__.
355  
-
356  
-__ http://fabfile.org/
357  
-
358  
-Below, and in the following sections, we'll show off a few example fabfiles
359  
-(i.e. Fabric scripts) that automate these file deployment options. The syntax
360  
-of a fabfile is fairly straightforward but won't be covered here; consult
361  
-`Fabric's documentation`__, for a complete explanation of the syntax..
362  
-
363  
-__ http://docs.fabfile.org/
364  
-
365  
-So, a fabfile to deploy static files to a couple of web servers might look
366  
-something like::
367  
-
368  
-    from fabric.api import *
369  
-
370  
-    # Hosts to deploy onto
371  
-    env.hosts = ['www1.example.com', 'www2.example.com']
372  
-
373  
-    # Where your project code lives on the server
374  
-    env.project_root = '/home/www/myproject'
375  
-
376  
-    def deploy_static():
377  
-        with cd(env.project_root):
378  
-            run('./manage.py collectstatic -v0 --noinput')
379  
-
380  
-Serving static files from a dedicated server
381  
---------------------------------------------
382  
-
383  
-Most larger Django apps use a separate Web server -- i.e., one that's not also
384  
-running Django -- for serving static files. This server often runs a different
385  
-type of web server -- faster but less full-featured. Some good choices are:
386  
-
387  
-* lighttpd_
388  
-* Nginx_
389  
-* TUX_
390  
-* Cherokee_
391  
-* A stripped-down version of Apache_
392  
-
393  
-.. _lighttpd: http://www.lighttpd.net/
394  
-.. _Nginx: http://wiki.nginx.org/Main
395  
-.. _TUX: http://en.wikipedia.org/wiki/TUX_web_server
396  
-.. _Apache: http://httpd.apache.org/
397  
-.. _Cherokee: http://www.cherokee-project.com/
398  
-
399  
-Configuring these servers is out of scope of this document; check each
400  
-server's respective documentation for instructions.
401  
-
402  
-Since your static file server won't be running Django, you'll need to modify
403  
-the deployment strategy to look something like:
404  
-
405  
-* When your static files change, run :djadmin:`collectstatic` locally.
406  
-* Push your local :setting:`STATIC_ROOT` up to the static file server
407  
-  into the directory that's being served. ``rsync`` is a good
408  
-  choice for this step since it only needs to transfer the
409  
-  bits of static files that have changed.
410  
-
411  
-Here's how this might look in a fabfile::
412  
-
413  
-    from fabric.api import *
414  
-    from fabric.contrib import project
415  
-
416  
-    # Where the static files get collected locally
417  
-    env.local_static_root = '/tmp/static'
418  
-
419  
-    # Where the static files should go remotely
420  
-    env.remote_static_root = '/home/www/static.example.com'
421  
-
422  
-    @roles('static')
423  
-    def deploy_static():
424  
-        local('./manage.py collectstatic')
425  
-        project.rsync_project(
426  
-            remote_dir = env.remote_static_root,
427  
-            local_dir = env.local_static_root,
428  
-            delete = True
429  
-        )
430  
-
431  
-.. _staticfiles-from-cdn:
432  
-
433  
-Serving static files from a cloud service or CDN
434  
-------------------------------------------------
435  
-
436  
-Another common tactic is to serve static files from a cloud storage provider
437  
-like Amazon's S3__ and/or a CDN (content delivery network). This lets you
438  
-ignore the problems of serving static files, and can often make for
439  
-faster-loading webpages (especially when using a CDN).
440  
-
441  
-When using these services, the basic workflow would look a bit like the above,
442  
-except that instead of using ``rsync`` to transfer your static files to the
443  
-server you'd need to transfer the static files to the storage provider or CDN.
444  
-
445  
-There's any number of ways you might do this, but if the provider has an API a
446  
-:doc:`custom file storage backend </howto/custom-file-storage>` will make the
447  
-process incredibly simple. If you've written or are using a 3rd party custom
448  
-storage backend, you can tell :djadmin:`collectstatic` to use it by setting
449  
-:setting:`STATICFILES_STORAGE` to the storage engine.
450  
-
451  
-For example, if you've written an S3 storage backend in
452  
-``myproject.storage.S3Storage`` you could use it with::
453  
-
454  
-    STATICFILES_STORAGE = 'myproject.storage.S3Storage'
455  
-
456  
-Once that's done, all you have to do is run :djadmin:`collectstatic` and your
457  
-static files would be pushed through your storage package up to S3. If you
458  
-later needed to switch to a different storage provider, it could be as simple
459  
-as changing your :setting:`STATICFILES_STORAGE` setting.
460  
-
461  
-For details on how you'd write one of these backends,
462  
-:doc:`/howto/custom-file-storage`.
463  
-
464  
-.. seealso::
465  
-
466  
-    The `django-storages`__ project is a 3rd party app that provides many
467  
-    storage backends for many common file storage APIs (including `S3`__).
468  
-
469  
-__ http://s3.amazonaws.com/
470  
-__ http://code.larlet.fr/django-storages/
471  
-__ http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html
472  
-
473  
-Upgrading from ``django-staticfiles``
474  
-=====================================
  91
+Deployment
  92
+==========
475 93
 
476  
-``django.contrib.staticfiles`` began its life as `django-staticfiles`_. If
477  
-you're upgrading from `django-staticfiles`_ older than 1.0 (e.g. 0.3.4) to
478  
-``django.contrib.staticfiles``, you'll need to make a few changes:
  94
+:mod:`django.contrib.staticfiles` provides a convenience management command
  95
+for gathering static files in a single directory so you can serve them easily.
479 96
 
480  
-* Application files should now live in a ``static`` directory in each app
481  
-  (`django-staticfiles`_ used the name ``media``, which was slightly
482  
-  confusing).
  97
+1. Set the :setting:`STATIC_ROOT` setting to the directory from which you'd
  98
+   like to serve these files, for example::
483 99
 
484  
-* The management commands ``build_static`` and ``resolve_static`` are now
485  
-  called :djadmin:`collectstatic` and :djadmin:`findstatic`.
  100
+       STATIC_ROOT = "/var/www/example.com/static/"
486 101
 
487  
-* The settings ``STATICFILES_PREPEND_LABEL_APPS``,
488  
-  ``STATICFILES_MEDIA_DIRNAMES`` and ``STATICFILES_EXCLUDED_APPS`` were
489  
-  removed.
  102
+2. Run the :djadmin:`collectstatic` management command::
490 103
 
491  
-* The setting ``STATICFILES_RESOLVERS`` was removed, and replaced by the
492  
-  new :setting:`STATICFILES_FINDERS`.
  104
+       ./manage.py collectstatic
493 105
 
494  
-* The default for :setting:`STATICFILES_STORAGE` was renamed from
495  
-  ``staticfiles.storage.StaticFileStorage`` to
496  
-  ``staticfiles.storage.StaticFilesStorage``
  106
+   This will copy all files from your static folders into the
  107
+   :setting:`STATIC_ROOT` directory.
497 108
 
498  
-* If using :ref:`runserver<staticfiles-runserver>` for local development
499  
-  (and the :setting:`DEBUG` setting is ``True``), you no longer need to add
500  
-  anything to your URLconf for serving static files in development.
  109
+3. Use a webserver of your choice to serve the
  110
+   files. :doc:`/howto/static-files/deployment` covers some common deployment
  111
+   strategies for static files.
501 112
 
502 113
 Learn more
503 114
 ==========
504 115
 
505 116
 This document has covered the basics and some common usage patterns. For
506 117
 complete details on all the settings, commands, template tags, and other pieces
507  
-include in ``django.contrib.staticfiles``, see :doc:`the staticfiles reference
508  
-</ref/contrib/staticfiles>`.
  118
+included in :mod:`django.contrib.staticfiles`, see :doc:`the staticfiles
  119
+reference </ref/contrib/staticfiles>`.
3  docs/index.txt
@@ -99,6 +99,7 @@ to know about views via the links below:
99 99
   :doc:`Decorators <topics/http/decorators>`
100 100
 
101 101
 * **Reference:**
  102
+  :doc:`Built-in Views <ref/views>` |
102 103
   :doc:`Request/response objects <ref/request-response>` |
103 104
   :doc:`TemplateResponse objects <ref/template-response>`
104 105
 
@@ -191,7 +192,7 @@ testing of Django applications:
191 192
   :doc:`Overview <howto/deployment/index>` |
192 193
   :doc:`WSGI servers <howto/deployment/wsgi/index>` |
193 194
   :doc:`FastCGI/SCGI/AJP <howto/deployment/fastcgi>` |
194  
-  :doc:`Handling static files <howto/static-files>` |
  195
+  :doc:`Deploying static files <howto/static-files/deployment>` |
195 196
   :doc:`Tracking code errors by email <howto/error-reporting>`
196 197
 
197 198
 The admin
2  docs/intro/overview.txt
@@ -272,7 +272,7 @@ following blocks." In short, that lets you dramatically cut down on redundancy
272 272
 in templates: each template has to define only what's unique to that template.
273 273
 
274 274
 Here's what the "base.html" template, including the use of :doc:`static files
275  
-</howto/static-files>`, might look like:
  275
+</howto/static-files/index>`, might look like:
276 276
 
277 277
 .. code-block:: html+django
278 278
 
2  docs/intro/tutorial06.txt
@@ -108,7 +108,7 @@ loaded in the bottom right of the screen.
108 108
 
109 109
 These are the **basics**. For more details on settings and other bits included
110 110
 with the framework see
111  
-:doc:`the static files howto </howto/static-files>` and the
  111
+:doc:`the static files howto </howto/static-files/index>` and the
112 112
 :doc:`the staticfiles reference </ref/contrib/staticfiles>`. :doc:`Deploying
113 113
 static files </howto/static-files/deployment>` discusses how to use static
114 114
 files on a real server.
29  docs/ref/contrib/staticfiles.txt
@@ -12,7 +12,8 @@ can easily be served in production.
12 12
 .. seealso::
13 13
 
14 14
     For an introduction to the static files app and some usage examples, see
15  
-    :doc:`/howto/static-files`.
  15
+    :doc:`/howto/static-files/index`. For guidelines on deploying static files,
  16
+    see :doc:`/howto/static-files/deployment`.
16 17
 
17 18
 .. _staticfiles-settings:
18 19
 
@@ -422,9 +423,18 @@ files:
422 423
 Static file development view
423 424
 ----------------------------
424 425
 
  426
+.. currentmodule:: django.contrib.staticfiles
  427
+
  428
+The static files tools are mostly designed to help with getting static files
  429
+successfully deployed into production. This usually means a separate,
  430
+dedicated static file server, which is a lot of overhead to mess with when
  431
+developing locally. Thus, the ``staticfiles`` app ships with a
  432
+**quick and dirty helper view** that you can use to serve files locally in
  433
+development.
  434
+
425 435
 .. highlight:: python
426 436
 
427  
-.. function:: django.contrib.staticfiles.views.serve(request, path)
  437
+.. function:: views.serve(request, path)
428 438
 
429 439
 This view function serves static files in development.
430 440
 
@@ -451,9 +461,10 @@ primary URL configuration::
451 461
 Note, the beginning of the pattern (``r'^static/'``) should be your
452 462
 :setting:`STATIC_URL` setting.
453 463
 
454  
-Since this is a bit finicky, there's also a helper function that'll do this for you:
  464
+Since this is a bit finicky, there's also a helper function that'll do this for
  465
+you:
455 466
 
456  
-.. function:: django.contrib.staticfiles.urls.staticfiles_urlpatterns()
  467
+.. function:: urls.staticfiles_urlpatterns()
457 468
 
458 469
 This will return the proper URL pattern for serving static files to your
459 470
 already defined pattern list. Use it like this::
@@ -464,8 +475,18 @@ already defined pattern list. Use it like this::
464 475
 
465 476
    urlpatterns += staticfiles_urlpatterns()
466 477
 
  478
+This will inspect your :setting:`STATIC_URL` setting and wire up the view
  479
+to serve static files accordingly. Don't forget to set the
  480
+:setting:`STATICFILES_DIRS` setting appropriately to let
  481
+``django.contrib.staticfiles`` know where to look for files in addition to
  482
+files in app directories.
  483
+
467 484
 .. warning::
468 485
 
469 486
     This helper function will only work if :setting:`DEBUG` is ``True``
470 487
     and your :setting:`STATIC_URL` setting is neither empty nor a full
471 488
     URL such as ``http://static.example.com/``.
  489
+
  490
+    That's because this view is **grossly inefficient** and probably
  491
+    **insecure**. This is only intended for local development, and should
  492
+    **never be used in production**.
7  docs/ref/django-admin.txt
@@ -720,7 +720,8 @@ Serving static files with the development server
720 720
 
721 721
 By default, the development server doesn't serve any static files for your site
722 722
 (such as CSS files, images, things under :setting:`MEDIA_URL` and so forth). If
723  
-you want to configure Django to serve static media, read :doc:`/howto/static-files`.
  723
+you want to configure Django to serve static media, read
  724
+:doc:`/howto/static-files/index`.
724 725
 
725 726
 shell
726 727
 -----
@@ -1235,7 +1236,7 @@ collectstatic
1235 1236
 ~~~~~~~~~~~~~
1236 1237
 
1237 1238
 This command is only available if the :doc:`static files application
1238  
-</howto/static-files>` (``django.contrib.staticfiles``) is installed.
  1239
+</howto/static-files/index>` (``django.contrib.staticfiles``) is installed.
1239 1240
 
1240 1241
 Please refer to its :djadmin:`description <collectstatic>` in the
1241 1242
 :doc:`staticfiles </ref/contrib/staticfiles>` documentation.
@@ -1244,7 +1245,7 @@ findstatic
1244 1245
 ~~~~~~~~~~
1245 1246
 
1246 1247
 This command is only available if the :doc:`static files application
1247  
-</howto/static-files>` (``django.contrib.staticfiles``) is installed.
  1248
+</howto/static-files/index>` (``django.contrib.staticfiles``) is installed.
1248 1249
 
1249 1250
 Please refer to its :djadmin:`description <findstatic>` in the :doc:`staticfiles
1250 1251
 </ref/contrib/staticfiles>` documentation.
1  docs/ref/index.txt
@@ -25,3 +25,4 @@ API Reference
25 25
    urls
26 26
    utils
27 27
    validators
  28
+   views
8  docs/ref/settings.txt
@@ -1250,9 +1250,9 @@ see the current list of translated languages by looking in
1250 1250
 
1251 1251
 .. _online source: https://github.com/django/django/blob/master/django/conf/global_settings.py
1252 1252
 
1253  
-The list is a tuple of two-tuples in the format 
1254  
-(:term:`language code<language code>`, ``language name``) -- for example, 
1255  
-``('ja', 'Japanese')``. 
  1253
+The list is a tuple of two-tuples in the format
  1254
+(:term:`language code<language code>`, ``language name``) -- for example,
  1255
+``('ja', 'Japanese')``.
1256 1256
 This specifies which languages are available for language selection. See
1257 1257
 :doc:`/topics/i18n/index`.
1258 1258
 
@@ -1912,7 +1912,7 @@ Example: ``"/var/www/example.com/static/"``
1912 1912
 If the :doc:`staticfiles</ref/contrib/staticfiles>` contrib app is enabled
1913 1913
 (default) the :djadmin:`collectstatic` management command will collect static
1914 1914
 files into this directory. See the howto on :doc:`managing static
1915  
-files</howto/static-files>` for more details about usage.
  1915
+files</howto/static-files/index>` for more details about usage.
1916 1916
 
1917 1917
 .. warning::
1918 1918
 
6  docs/ref/templates/builtins.txt
@@ -2388,8 +2388,10 @@ slightly different call::
2388 2388
     The :mod:`staticfiles<django.contrib.staticfiles>` contrib app also ships
2389 2389
     with a :ttag:`static template tag<staticfiles-static>` which uses
2390 2390
     ``staticfiles'`` :setting:`STATICFILES_STORAGE` to build the URL of the
2391  
-    given path. Use that instead if you have an advanced use case such as
2392  
-    :ref:`using a cloud service to serve static files<staticfiles-from-cdn>`::
  2391
+    given path (rather than simply using :func:`urlparse.urljoin` with the
  2392
+    :setting:`STATIC_URL` setting and the given path). Use that instead if you
  2393
+    have an advanced use case such as :ref:`using a cloud service to serve
  2394
+    static files<staticfiles-from-cdn>`::
2393 2395
 
2394 2396
         {% load static from staticfiles %}
2395 2397
         <img src="{% static "images/hi.jpg" %}" alt="Hi!" />
14  docs/ref/urls.txt
@@ -52,6 +52,20 @@ The ``optional_dictionary`` and ``optional_name`` parameters are described in
52 52
     patterns you can construct. The only limit is that you can only create 254
53 53
     at a time (the 255th argument is the initial prefix argument).
54 54
 
  55
+static()
  56
+--------
  57
+
  58
+.. function:: static.static(prefix, view='django.views.static.serve', **kwargs)
  59
+
  60
+Helper function to return a URL pattern for serving files in debug mode::
  61
+
  62
+    from django.conf import settings
  63
+    from django.conf.urls.static import static
  64
+
  65
+    urlpatterns = patterns('',
  66
+        # ... the rest of your URLconf goes here ...
  67
+    ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  68
+
55 69
 url()
56 70
 -----
57 71
 
48  docs/ref/views.txt
... ...
@@ -0,0 +1,48 @@
  1
+==============
  2
+Built-in Views
  3
+==============
  4
+
  5
+.. module:: django.views
  6
+   :synopsis: Django's built-in views.
  7
+
  8
+Several of Django's built-in views are documented in
  9
+:doc:`/topics/http/views` as well as elsewhere in the documentation.
  10
+
  11
+Serving files in development
  12
+----------------------------
  13
+
  14
+.. function:: static.serve(request, path, document_root, show_indexes=False)
  15
+
  16
+There may be files other than your project's static assets that, for
  17
+convenience, you'd like to have Django serve for you in local development.
  18
+The :func:`~django.views.static.serve` view can be used to serve any directory
  19
+you give it. (This view is **not** hardened for production use and should be
  20
+used only as a development aid; you should serve these files in production
  21
+using a real front-end webserver).
  22
+
  23
+The most likely example is user-uploaded content in :setting:`MEDIA_ROOT`.
  24
+``django.contrib.staticfiles`` is intended for static assets and has no
  25
+built-in handling for user-uploaded files, but you can have Django serve your
  26
+:setting:`MEDIA_ROOT` by appending something like this to your URLconf::
  27
+
  28
+    from django.conf import settings
  29
+
  30
+    # ... the rest of your URLconf goes here ...
  31
+
  32
+    if settings.DEBUG:
  33
+        urlpatterns += patterns('',
  34
+            url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
  35
+                'document_root': settings.MEDIA_ROOT,
  36
+            }),
  37
+       )
  38
+
  39
+Note, the snippet assumes your :setting:`MEDIA_URL` has a value of
  40
+``'/media/'``. This will call the :func:`~django.views.static.serve` view,
  41
+passing in the path from the URLconf and the (required) ``document_root``
  42
+parameter.
  43
+
  44
+Since it can become a bit cumbersome to define this URL pattern, Django
  45
+ships with a small URL helper function :func:`~django.conf.urls.static.static`
  46
+that takes as parameters the prefix such as :setting:`MEDIA_URL` and a dotted
  47
+path to a view, such as ``'django.views.static.serve'``. Any other function
  48
+parameter will be transparently passed to the view.
2  docs/releases/1.3-alpha-1.txt
@@ -72,7 +72,7 @@ at :setting:`STATIC_URL`.
72 72
 
73 73
 See the :doc:`reference documentation of the app </ref/contrib/staticfiles>`
74 74
 for more details or learn how to :doc:`manage static files
75  
-</howto/static-files>`.
  75
+</howto/static-files/index>`.
76 76
 
77 77
 ``unittest2`` support
78 78
 ~~~~~~~~~~~~~~~~~~~~~
2  docs/releases/1.3-beta-1.txt
@@ -37,7 +37,7 @@ Based on feedback from the community this release adds two new options to the
37 37
 
38 38
 See the :doc:`staticfiles reference documentation </ref/contrib/staticfiles>`
39 39
 for more details, or learn :doc:`how to manage static files
40  
-</howto/static-files>`.
  40
+</howto/static-files/index>`.
41 41
 
42 42
 Translation comments
43 43
 ~~~~~~~~~~~~~~~~~~~~
2  docs/releases/1.3.txt
@@ -115,7 +115,7 @@ at :setting:`STATIC_URL`.
115 115
 
116 116
 See the :doc:`reference documentation of the app </ref/contrib/staticfiles>`
117 117
 for more details or learn how to :doc:`manage static files
118  
-</howto/static-files>`.
  118
+</howto/static-files/index>`.
119 119
 
120 120
 unittest2 support
121 121
 ~~~~~~~~~~~~~~~~~
2  docs/releases/1.4-alpha-1.txt
@@ -578,7 +578,7 @@ If you've previously used a URL path for ``ADMIN_MEDIA_PREFIX`` (e.g.
578 578
 ``/media/``) simply make sure :setting:`STATIC_URL` and :setting:`STATIC_ROOT`
579 579
 are configured and your web server serves the files correctly. The development
580 580
 server continues to serve the admin files just like before. Don't hesitate to
581  
-consult the :doc:`static files howto </howto/static-files>` for further
  581
+consult the :doc:`static files howto </howto/static-files/index>` for further
582 582
 details.
583 583
 
584 584
 In case your ``ADMIN_MEDIA_PREFIX`` is set to an specific domain (e.g.
2  docs/releases/1.4-beta-1.txt
@@ -646,7 +646,7 @@ If you've previously used a URL path for ``ADMIN_MEDIA_PREFIX`` (e.g.
646 646
 ``/media/``) simply make sure :setting:`STATIC_URL` and :setting:`STATIC_ROOT`
647 647
 are configured and your web server serves the files correctly. The development
648 648
 server continues to serve the admin files just like before. Don't hesitate to
649  
-consult the :doc:`static files howto </howto/static-files>` for further
  649
+consult the :doc:`static files howto </howto/static-files/index>` for further
650 650
 details.
651 651
 
652 652
 In case your ``ADMIN_MEDIA_PREFIX`` is set to an specific domain (e.g.
2  docs/releases/1.4.txt
@@ -708,7 +708,7 @@ If you've previously used a URL path for ``ADMIN_MEDIA_PREFIX`` (e.g.
708 708
 ``/media/``) simply make sure :setting:`STATIC_URL` and :setting:`STATIC_ROOT`
709 709
 are configured and your Web server serves those files correctly. The
710 710
 development server continues to serve the admin files just like before. Read
711  
-the :doc:`static files howto </howto/static-files>` for more details.
  711
+the :doc:`static files howto </howto/static-files/index>` for more details.
712 712
 
713 713
 If your ``ADMIN_MEDIA_PREFIX`` is set to an specific domain (e.g.
714 714
 ``http://media.example.com/admin/``), make sure to also set your
2  docs/topics/files.txt
@@ -5,7 +5,7 @@ Managing files
5 5
 This document describes Django's file access APIs for files such as those
6 6
 uploaded by a user. The lower level APIs are general enough that you could use
7 7
 them for other purposes. If you want to handle "static files" (JS, CSS, etc),
8  
-see :doc:`/howto/static-files`.
  8
+see :doc:`/howto/static-files/index`.
9 9
 
10 10
 By default, Django stores files locally, using the :setting:`MEDIA_ROOT` and
11 11
 :setting:`MEDIA_URL` settings. The examples below assume that you're using these
2  docs/topics/testing/overview.txt
@@ -1094,7 +1094,7 @@ out the `full reference`_ for more details.
1094 1094
 .. note::
1095 1095
 
1096 1096
     ``LiveServerTestCase`` makes use of the :doc:`staticfiles contrib app
1097  
-    </howto/static-files>` so you'll need to have your project configured
  1097
+    </howto/static-files/index>` so you'll need to have your project configured
1098 1098
     accordingly (in particular by setting :setting:`STATIC_URL`).
1099 1099
 
1100 1100
 .. note::

0 notes on commit c3779d4

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