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.
(set_prefix=True)
| 6 | |
| 7 | |
| 8 | def setup(set_prefix=True): |
| 9 | """ |
| 10 | Configure the settings (this happens as a side effect of accessing the |
| 11 | first setting), configure logging and populate the app registry. |
| 12 | Set the thread-local urlresolvers script prefix if `set_prefix` is True. |
| 13 | """ |
| 14 | from django.apps import apps |
| 15 | from django.conf import settings |
| 16 | from django.urls import set_script_prefix |
| 17 | from django.utils.log import configure_logging |
| 18 | |
| 19 | configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) |
| 20 | if set_prefix: |
| 21 | set_script_prefix( |
| 22 | "/" if settings.FORCE_SCRIPT_NAME is None else settings.FORCE_SCRIPT_NAME |
| 23 | ) |
| 24 | apps.populate(settings.INSTALLED_APPS) |