numegil
numegil

Reputation: 1926

Django can't find settings

I have a Django project that contains a "config" folder, which has a settings_dev.py file inside of it which is my settings file.

If I try doing anything with manage.py, it complains that it can't find my settings file, even if I explicitly provide it via the --settings option, e.g.

python manage.py syncdb --settings=config.settings_dev
Error: Can't find the file 'settings.py' in the directory containing 'manage.py'. It appears you've customized things.
You'll have to run django-admin.py, passing it your settings module.

However, if I rename my "config" folder to "settings", it works fine. e.g.

python manage.py syncdb --settings=settings.settings_dev

works fine.

What else do I need to specify for it to know that my settings folder is actually named config?

Upvotes: 4

Views: 14048

Answers (3)

sbaechler
sbaechler

Reputation: 1429

Have a look at this answer:

This error occurs as well if there is an import error within settings.py.

https://stackoverflow.com/questions/6036599/bizarre-error-importing-settings-in-django#=

Upvotes: 0

erikvw
erikvw

Reputation: 426

create a generic settings.py in the project folder that points to the config module. don't forget the __init__.py in the config folder. This might be better than modifying manage.py.

#!/usr/bin/env python
from django.core.management import setup_environ
try:
    import config.settings as settings
except ImportError:
    import sys
    sys.stderr.write("Couldn't find the settings.py module.")
    sys.exit(1)
setup_environ(settings)

Upvotes: 2

szaman
szaman

Reputation: 6756

Look into manage.py. It tries to import settings not conf. You have to modify your manage.py file

Upvotes: 4

Related Questions