mirror of
https://github.com/django/django.git
synced 2025-10-26 15:16:09 +00:00
Populated models only when necessary in get_app_config[s].
Took this opportunity to change get_app[s] to only consider applications containing a model module as that seems slightly more backwards compatible. Since callers that care about models pass only_with_models_module=True, this has very few consequences. Only AppCommand needed a change.
This commit is contained in:
@@ -344,6 +344,11 @@ class AppCommand(BaseCommand):
|
||||
from django.core.apps import app_cache
|
||||
if not app_labels:
|
||||
raise CommandError('Enter at least one appname.')
|
||||
# Populate models and don't use only_with_models_module=True when
|
||||
# calling get_app_config() to tell apart missing apps from apps
|
||||
# without a model module -- which can't be supported with the legacy
|
||||
# API since it passes the models module to handle_app().
|
||||
app_cache.populate_models()
|
||||
try:
|
||||
app_configs = [app_cache.get_app_config(app_label) for app_label in app_labels]
|
||||
except (LookupError, ImportError) as e:
|
||||
|
||||
Reference in New Issue
Block a user