From e2b4c142819c048b8b6eaff913da56f11688457a Mon Sep 17 00:00:00 2001 From: Ben Cail Date: Wed, 13 Nov 2024 13:57:29 -0500 Subject: [PATCH] remove unnecessary call to settings.INSTALLED_APPS --- django/core/management/__init__.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index 5147d7637b..f323f57567 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -254,16 +254,9 @@ class ManagementUtility: try: app_name = commands[subcommand] except KeyError: - if os.environ.get("DJANGO_SETTINGS_MODULE"): - if self.settings_exception: - sys.stderr.write(str(self.settings_exception) + "\n") - sys.exit(1) - else: - # If `subcommand` is missing due to misconfigured settings, the - # following line will retrigger an ImproperlyConfigured exception - # (get_commands() swallows the original one) so the user is - # informed about it. - settings.INSTALLED_APPS + if os.environ.get("DJANGO_SETTINGS_MODULE") and self.settings_exception: + sys.stderr.write(str(self.settings_exception) + "\n") + sys.exit(1) elif not settings.configured: sys.stderr.write("No Django settings specified.\n") possible_matches = get_close_matches(subcommand, commands)