Opened 11 years ago

Closed 11 years ago

#5201 closed (invalid)

Settings won't load when inside a directory named settings

Reported by: Deryck Hodge <deryck@…> Owned by: Adrian Holovaty
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I think something has happened since the refatoring of management so that you can no longer have a directory named settings which contains your settings files. For example, I have a directory on my PYTHONPATH which has all my apps I'm working on and then a settings directory which has and inside. Something like:

  -- app1
  -- app2
  -- settings

Normally, I run the with DJANGO_SETTINGS_MODULE=settings.devel, but I noticed today that this no longer works.

See this Traceback that might help explain and also shows this worked with a SVN rev prior to r5898

naminanu:~ hodgedg$ export PYTHONPATH=~/projects/django_trunk_r5897:~/projects/paperlate
naminanu:~ hodgedg$ export DJANGO_SETTINGS_MODULE=settings.devel
naminanu:~ hodgedg$ validate 
0 errors found.
naminanu:~ hodgedg$ export PYTHONPATH=~/projects/django/SVN/django/trunk:~/projects/paperlate
naminanu:~ hodgedg$ export DJANGO_SETTINGS_MODULE=settings.devel
naminanu:~ hodgedg$ validate 
Traceback (most recent call last):
  File "/Users/hodgedg/projects/django/SVN/django/trunk/django/bin/", line 5, in <module>
  File "/Users/hodgedg/projects/django/SVN/django/trunk/django/core/management/", line 171, in execute_from_command_line
  File "/Users/hodgedg/projects/django/SVN/django/trunk/django/core/management/", line 124, in execute
    command.execute(*args[1:], **options.__dict__)
  File "/Users/hodgedg/projects/django/SVN/django/trunk/django/core/management/", line 28, in execute
  File "/Users/hodgedg/projects/django/SVN/django/trunk/django/utils/translation/", line 76, in activate
    return real_activate(language)
  File "/Users/hodgedg/projects/django/SVN/django/trunk/django/utils/translation/", line 31, in delayed_loader
    if settings.USE_I18N:
  File "/Users/hodgedg/projects/django/SVN/django/trunk/django/conf/", line 28, in __getattr__
  File "/Users/hodgedg/projects/django/SVN/django/trunk/django/conf/", line 57, in _import_settings
    self._target = Settings(settings_module)
  File "/Users/hodgedg/projects/django/SVN/django/trunk/django/conf/", line 85, in __init__
    raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
EnvironmentError: Could not import settings 'settings.devel' (Is it on sys.path? Does it have syntax errors?): No module named devel
naminanu:~ hodgedg$ cp -r ~/projects/paperlate/settings/ ~/projects/paperlate/testing/
naminanu:~ hodgedg$ export DJANGO_SETTINGS_MODULE=testing.devel
naminanu:~ hodgedg$ validate 
naminanu:~ hodgedg$

Notice that renaming the directory to something other than "settings" fixes the problem. Also, this Tracebook occurred in Trunk against r5919.

Change History (1)

comment:1 Changed 11 years ago by Deryck Hodge <deryck@…>

Resolution: invalid
Status: newclosed

Okay, I feel stupid. I had added a inside django for testing which feel on my PYTHONPATH.

Please forgive the ticket noise.

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