我想用一個不同的設置文件在Django - 特別settings_prod - 但每當我試圖做一個執行syncdb與--settings=settings_prod
,它抱怨:使用設置文件以外的其他settings.py在Django
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.)
我也嘗試過設置環境變量DJANGO_SETTINGS_MODULE=settings_prod
到最後。
編輯:我還設置環境變量在我的WSGI文件,還沒有結束:
import os
import sys
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings_prod'
application = WSGIHandler()
建議?
並與WSGI是它正常工作?我之前遇到過這個問題,但只有'manage.py' – pajton 2011-03-29 00:36:36
我這麼認爲,因爲它至少顯示了我設置的URL。我只是不能把它到syncdb。 – 2011-03-29 00:38:51
好吧,有人只是回答了我的想法:)。 'import settings'在'manage.py'中被硬編碼,所以沒有這個簡單的方法。 – pajton 2011-03-29 00:40:31