1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #16734 -- Set script prefix even outside of requests

Thanks Tim Graham for the review.
This commit is contained in:
Claude Paroz
2015-10-23 21:02:34 +02:00
parent 9dcfecb7c6
commit 7d81ee6efc
8 changed files with 64 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
from __future__ import unicode_literals
from django.utils.version import get_version
VERSION = (1, 10, 0, 'alpha', 0)
@@ -5,14 +7,21 @@ VERSION = (1, 10, 0, 'alpha', 0)
__version__ = get_version(VERSION)
def setup():
def setup(set_prefix=True):
"""
Configure the settings (this happens as a side effect of accessing the
first setting), configure logging and populate the app registry.
Set the thread-local urlresolvers script prefix if `set_prefix` is True.
"""
from django.apps import apps
from django.conf import settings
from django.core.urlresolvers import set_script_prefix
from django.utils.encoding import force_text
from django.utils.log import configure_logging
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
if set_prefix:
set_script_prefix(
'/' if settings.FORCE_SCRIPT_NAME is None else force_text(settings.FORCE_SCRIPT_NAME)
)
apps.populate(settings.INSTALLED_APPS)