mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #16734 -- Set script prefix even outside of requests
Thanks Tim Graham for the review.
This commit is contained in:
parent
9dcfecb7c6
commit
7d81ee6efc
8 changed files with 64 additions and 5 deletions
|
@ -332,14 +332,20 @@ application registry.
|
|||
|
||||
.. currentmodule:: django
|
||||
|
||||
.. function:: setup()
|
||||
.. function:: setup(set_script=True)
|
||||
|
||||
Configures Django by:
|
||||
|
||||
* Loading the settings.
|
||||
* Setting up logging.
|
||||
* If ``set_script`` is True, setting the URL resolver script prefix to
|
||||
:setting:`FORCE_SCRIPT_NAME` if defined, or ``/`` otherwise.
|
||||
* Initializing the application registry.
|
||||
|
||||
.. versionchanged:: 1.10
|
||||
|
||||
The ability to set the URL resolver script prefix is new.
|
||||
|
||||
This function is called automatically:
|
||||
|
||||
* When running an HTTP server via Django's WSGI support.
|
||||
|
|
|
@ -1408,7 +1408,14 @@ Default: ``None``
|
|||
If not ``None``, this will be used as the value of the ``SCRIPT_NAME``
|
||||
environment variable in any HTTP request. This setting can be used to override
|
||||
the server-provided value of ``SCRIPT_NAME``, which may be a rewritten version
|
||||
of the preferred value or not supplied at all.
|
||||
of the preferred value or not supplied at all. It is also used by
|
||||
:func:`django.setup()` to set the URL resolver script prefix outside of the
|
||||
request/response cycle (e.g. in management commands and standalone scripts) to
|
||||
generate correct URLs when ``SCRIPT_NAME`` is not ``/``.
|
||||
|
||||
.. versionchanged:: 1.10
|
||||
|
||||
The setting's use in :func:`django.setup()` was added.
|
||||
|
||||
.. setting:: FORMAT_MODULE_PATH
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue