#20443: Import errors in settings cause confusing error messages
-------------------------------+--------------------
Reporter: erikr | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords: dceu13
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20443>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.