﻿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
28791	ManagementUtility.execute() does not handle ImportError for invalid settings module	Marten Kenbeek	Hrishikesh Barman	"In [https://github.com/django/django/blob/abaf0ab4a444977dc8ac07b9b63256814c352245/django/core/management/__init__.py#L316 ManagementUtility.execute()], the code tries to load the settings, and catches `ImproperlyConfigured` in case the settings aren't configured. However, if `DJANGO_SETTINGS_MODULE` is set to an invalid module (e.g. from the previous project you were working on), an uncaught `ImportError` is raised. This causes commands that don't need the settings, such as `startproject`, to fail.

It seems to me that the `ImportError` can safely be caught so that core commands that don't need settings can be executed. If the settings are accessed later on (either because the command [https://github.com/django/django/blob/abaf0ab4a444977dc8ac07b9b63256814c352245/django/core/management/__init__.py#L198 can't be found] or the command uses the settings), the `ImportError` will be reraised. "	Cleanup/optimization	closed	Core (Management commands)	dev	Normal	fixed		Hrishikesh Barman Adam Johnson	Accepted	1	0	1	1	1	0
