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?
Insights about settings.py file. A Django settings file contains all the configuration of your Django Project. In this article the important points of settings.py file of Django will be discussed. A settings file is just a Python module with module-level variables.
A Django settings file doesn't have to define any settings if it doesn't need to. Each setting has a sensible default value. These defaults live in the module django/conf/global_settings.py .
Try creating a settings
module.
settings
folder in the same directory as manage.py
.base.py
and prod.py
).Make __init__.py
and import whatever settings you want to use as your default. For example, your __init__.py
file might look like this:
from base import *
Run your project and override the settings:
$ python2.6 manage.py syncdb --settings=settings.prod
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With