1
0
mirror of https://github.com/django/django.git synced 2025-10-29 00:26:07 +00:00

Stopped populating the app registry as a side effect.

Since it triggers imports, it shouldn't be done lightly.

This commit adds a public API for doing it explicitly, django.setup(),
and does it automatically when using manage.py and wsgi.py.
This commit is contained in:
Aymeric Augustin
2013-12-30 15:42:15 +01:00
parent 7ed20e0153
commit 80d74097b4
13 changed files with 65 additions and 52 deletions

View File

@@ -6,3 +6,12 @@ def get_version(*args, **kwargs):
# Only import if it's actually called.
from django.utils.version import get_version
return get_version(*args, **kwargs)
def setup():
# Configure the settings (this happens as a side effect of accessing
# INSTALLED_APPS or any other setting) and populate the app registry.
from django.apps import apps
from django.conf import settings
apps.populate_apps(settings.INSTALLED_APPS)
apps.populate_models()