Fixed #25598 -- Added SCRIPT_NAME prefix to STATIC_URL and MEDIA_URL set to relative paths.

Thanks Florian Apolloner for reviews.

Co-authored-by: Joel Dunham <Joel.Dunham@technicalsafetybc.ca>
This commit is contained in:
Oleg Kainov 2018-12-05 16:15:33 -08:00 committed by Mariusz Felisiak
parent 580e644f24
commit c574bec092
5 changed files with 99 additions and 2 deletions

View file

@ -1989,6 +1989,13 @@ Example: ``"http://media.example.com/"``
:setting:`MEDIA_URL` and :setting:`STATIC_URL` must have different
values. See :setting:`MEDIA_ROOT` for more details.
.. note::
If :setting:`MEDIA_URL` is a relative path, then it will be prefixed by the
server-provided value of ``SCRIPT_NAME`` (or ``/`` if not set). This makes
it easier to serve a Django application in a subpath without adding an
extra configuration to the settings.
.. setting:: MIDDLEWARE
``MIDDLEWARE``
@ -3306,6 +3313,13 @@ You may need to :ref:`configure these files to be served in development
<serving-static-files-in-development>` and will definitely need to do so
:doc:`in production </howto/static-files/deployment>`.
.. note::
If :setting:`STATIC_URL` is a relative path, then it will be prefixed by
the server-provided value of ``SCRIPT_NAME`` (or ``/`` if not set). This
makes it easier to serve a Django application in a subpath without adding
an extra configuration to the settings.
.. setting:: STATICFILES_DIRS
``STATICFILES_DIRS``

View file

@ -233,6 +233,11 @@ Miscellaneous
* The compatibility imports of ``Context``, ``ContextPopException``, and
``RequestContext`` in ``django.template.base`` are removed.
* The :setting:`STATIC_URL` and :setting:`MEDIA_URL` settings set to relative
paths are now prefixed by the server-provided value of ``SCRIPT_NAME`` (or
``/`` if not set). This change should not affect settings set to valid URLs
or absolute paths.
.. _deprecated-features-3.1:
Features deprecated in 3.1