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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user