django

Using a settings file other than settings.py in Django


I want to use a different settings file in django -- specifically settings_prod -- yet whenever I try to do a syncdb with --settings=settings_prod, it complains:

python2.6 manage.py syncdb  --settings=settings_prod
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.
(If the file settings.py does indeed exist, it's causing an ImportError somehow.)

I've also tried setting the environment variable DJANGO_SETTINGS_MODULE=settings_prod to no end.

Edit: I have also set the environment variable in my wsgi file, also to no end:

import os
import sys

from django.core.handlers.wsgi import WSGIHandler

os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings_prod'
application = WSGIHandler()

Suggestions?


Solution

  • I do know that no matter what you do with manage.py, you're going to get that error because manage.py does a relative import of settings:

    try:
        import settings # Assumed to be in the same directory.
    

    http://docs.djangoproject.com/en/dev/ref/django-admin/#django-admin-option---settings

    Note that this option is unnecessary in manage.py, because it uses settings.py from the current project by default.

    You should try django-admin.py syncdb --settings=mysettings instead