﻿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
20443	Import errors in settings cause confusing error messages	Sasha Romijn	nobody	"When the settings file itself has an import error, the error message suggests that the settings file could not be found. This can be very confusing, especially for new users.

Currently, the traceback is:
{{{
Traceback (most recent call last):
  File ""./manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""/Users/erik/dev/django/django/core/management/__init__.py"", line 399, in execute_from_command_line
    utility.execute()
  File ""/Users/erik/dev/django/django/core/management/__init__.py"", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/Users/erik/dev/django/django/core/management/__init__.py"", line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File ""/Users/erik/dev/django/django/core/management/__init__.py"", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File ""/Users/erik/dev/django/django/conf/__init__.py"", line 54, in __getattr__
    self._setup(name)
  File ""/Users/erik/dev/django/django/conf/__init__.py"", line 49, in _setup
    self._wrapped = Settings(settings_module)
  File ""/Users/erik/dev/django/django/conf/__init__.py"", line 130, in __init__
    raise ImportError(""Could not import settings '%s' (Is it on sys.path?): %s"" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'django5622.settings' (Is it on sys.path?): No module named foo
}}}

Whereas in reality the settings file was found, but contained an error.

Adding a bit of info on the original traceback makes this very obvious:

{{{
Traceback (most recent call last):
  File ""./manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""/Users/erik/dev/django/django/core/management/__init__.py"", line 399, in execute_from_command_line
    utility.execute()
  File ""/Users/erik/dev/django/django/core/management/__init__.py"", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/Users/erik/dev/django/django/core/management/__init__.py"", line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File ""/Users/erik/dev/django/django/core/management/__init__.py"", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File ""/Users/erik/dev/django/django/conf/__init__.py"", line 55, in __getattr__
    self._setup(name)
  File ""/Users/erik/dev/django/django/conf/__init__.py"", line 50, in _setup
    self._wrapped = Settings(settings_module)
  File ""/Users/erik/dev/django/django/conf/__init__.py"", line 135, in __init__
    raise ImportError(msg)
ImportError: Could not import settings 'django5622.settings' (Is it on sys.path?): No module named o in /Users/erik/dev/django5622/django5622/settings.py:12
}}}"	New feature	closed	Uncategorized	dev	Normal	fixed	dceu13	eromijn@…	Ready for checkin	1	0	0	0	1	0
