我想在django中使用不同的设置文件 - 特别是settings_prod  - 但每当我尝试使用syncdb时--settings=settings_prod,它会抱怨:
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()
建议?
Ell*_*ron 16
尝试创建一个settings模块.
settings在与...相同的目录中创建一个文件夹manage.py.base.py和prod.py).制作__init__.py并导入您要用作默认设置的任何设置.例如,您的__init__.py文件可能如下所示:
from base import *
运行项目并覆盖设置:
$ python2.6 manage.py syncdb --settings=settings.prod
Yuj*_*ita 10
我知道无论你做什么manage.py,你都会得到那个错误,因为manage.py相对导入settings:
try:
    import settings # Assumed to be in the same directory.
http://docs.djangoproject.com/en/dev/ref/django-admin/#django-admin-option---settings
请注意,manage.py中不需要此选项,因为它默认使用当前项目中的settings.py.
你应该尝试django-admin.py syncdb --settings=mysettings,而不是
| 归档时间: | 
 | 
| 查看次数: | 24940 次 | 
| 最近记录: |