Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21284 closed Bug (fixed)

Errors in the settings.py file result in misleading messages

Reported by: Anand Kumria Owned by: nobody
Component: Core (Management commands) Version: 1.6-beta-1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

If you have an error in your settings.py, Django 1.6 will give an error indicating that whatever command you are attempting to run does not exist.

$ django-admin.py startproject djtest .
$ python manage.py validate
0 errors found

Now edit djtest/settings.py and put the following in the file:

diff -u djtest.orig/settings.py djtest/settings.py
--- djtest.orig/settings.py 2013-10-17 14:18:51.348674346 +0100
+++ djtest/settings.py 2013-10-17 14:20:07.773667472 +0100
@@ -26,6 +26,7 @@

ALLOWED_HOSTS = []


+ENV_FACTOR_STUFF = os.environENV_FACTOR_STUFF

# Application definition


# (i.e. attempt to get something from the environment)

$ python manage.py validate
Unknown command: 'validate'
Type 'manage.py help' for usage.

$ python manage.py runserver
Unknown command: 'runserver'
Type 'manage.py help' for usage.

etc.

Change History (4)

comment:1 by Aymeric Augustin, 11 years ago

Does this only happen with KeyError, or also with other exceptions? For instance what happens if you put 1/0 in your settings file?

comment:2 by Claude Paroz, 11 years ago

Component: UncategorizedCore (Management commands)
Easy pickings: set
Triage Stage: UnreviewedAccepted

That issue is specific to KeyError, which is swallowed in fetch_command. But the workaround is trivial (separate get_commands() from getting the index).

comment:3 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 3514bcb251fb623dbd07911e53d417d55934ffa5:

Fixed #21284 -- Prevented KeyError swallowing in fetch_command

Thanks wildfire for the report.

comment:4 by Claude Paroz <claude@…>, 11 years ago

In 621fc1f1d74df2d9240dea88b5f7ebdf472bca38:

[1.6.x] Fixed #21284 -- Prevented KeyError swallowing in fetch_command

Thanks wildfire for the report.

Backport of 3514bcb251 from master.

Note: See TracTickets for help on using tickets.
Back to Top