Skip to content

Loading…

My patch for ticket 20284 #1120

Closed
wants to merge 3 commits into from

3 participants

@niconoe

As described at https://code.djangoproject.com/ticket/20284, it was lacking a mention that serving static assets in production was dependent on the DEBUG settings.

So I replaced the single line of text "Now, if you use ./manage.py runserver, all static files should be served automatically at the STATIC_URL and be shown correctly." by a more complete note block (also re-stating that this was not a proper solution for production environments, and added links to relevant documentation).

Please note that I'm not a native English speaker.

@mjtamlyn mjtamlyn commented on an outdated diff
docs/howto/static-files/index.txt
@@ -35,8 +35,21 @@ Configuring static files
4. Store your static files in a folder called ``static`` in your app. For
example ``my_app/static/my_app/myimage.jpg``.
-Now, if you use ``./manage.py runserver``, all static files should be served
-automatically at the :setting:`STATIC_URL` and be shown correctly.
+.. admonition:: Serving the files
+
+ In addition to these configuration steps, you'll also need to actually serve
+ the static files.
+
+ During development, this will be done automatically if you use :djadmin:`runserver`
+ and :setting:`DEBUG` is set to ``True`` (see
+ :class:`django.contrib.staticfiles.views.serve`).
@mjtamlyn Django member

This is a function, not a class I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mjtamlyn
Django member

Aside from a minor RST issue, this test looks good.

@niconoe

You're perfectly right ! This should be fixed now.

@timgraham
Django member

Thanks

@timgraham timgraham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 15 additions and 2 deletions.
  1. +15 −2 docs/howto/static-files/index.txt
View
17 docs/howto/static-files/index.txt
@@ -35,8 +35,21 @@ Configuring static files
4. Store your static files in a folder called ``static`` in your app. For
example ``my_app/static/my_app/myimage.jpg``.
-Now, if you use ``./manage.py runserver``, all static files should be served
-automatically at the :setting:`STATIC_URL` and be shown correctly.
+.. admonition:: Serving the files
+
+ In addition to these configuration steps, you'll also need to actually serve
+ the static files.
+
+ During development, this will be done automatically if you use :djadmin:`runserver`
+ and :setting:`DEBUG` is set to ``True`` (see
+ :func:`django.contrib.staticfiles.views.serve`).
+
+ This method is **grossly inefficient** and probably **insecure**,
+ so it is **unsuitable for production**.
+
+ See :doc:`/howto/static-files/deployment` for proper strategies to serve
+ static files in production environments.
+
Your project will probably also have static assets that aren't tied to a
particular app. In addition to using a ``static/`` directory inside your apps,
Something went wrong with that request. Please try again.