﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36422	Settings exception hidden when running management command	Lily Acorn		"When running a management command, Django tries to load `settings.INSTALLED_APPS` (https://github.com/django/django/blob/ad28db666e0884b658f5e240c3d7ee1362688ba1/django/core/management/__init__.py#L381-L386). If this fails with an `ImproperlyConfigured` or an `ImportError` exception, Django saves this as `self.settings_exception`. This is used to output help text (https://github.com/django/django/blob/ad28db666e0884b658f5e240c3d7ee1362688ba1/django/core/management/__init__.py#L235-L242) when the subcommand is `help` or the `--help` or `-h` flag is set. Otherwise the exception is completely swallowed, which is really unhelpful for identifying the cause of later failures.

In my case, I was getting a chain of `AppRegistryNotReady` exceptions from the `migrate` subcommand, but the root cause of an `ImproperlyConfigured` exception from my settings was deeply hidden, until I did some fairly deep exploration with `pdb`.

A suggested fix is to add `self.settings_exception` to the exception chain when a later exception is raised."	Bug	closed	Core (Management commands)	dev	Normal	duplicate		Lily Acorn	Unreviewed	0	0	0	0	0	0
