我正在尝试在AWS Elastic Beanstalk上部署我的django应用。部署后,打开网址时出现500内部错误。日志状态" ImportError:没有名为settings.production"的模块。我知道这意味着服务器无法找到我的设置文件,但它在我的本地工作正常。我觉得我错过了一些非常明显的东西。
省略了一些东西......
这是我的.ebextensions 02_python.config:
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "config.settings.production"
PYTHONPATH: "/opt/python/current/app/johngoben:$PYTHONPATH"
"ALLOWED_HOSTS": ".elasticbeanstalk.com"
"aws:elasticbeanstalk:container:python":
WSGIPath: site/config/wsgi.py
NumProcesses: 3
NumThreads: 20
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "www/static/"
这是我的wsgi配置:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.production")
os.environ["DJANGO_SETTINGS_MODULE"] = "settings.production"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
这是我的app结构
project-root/
.ebextensions/
01_packages.config
02_python.config
.elasticbeanstalk/
config
project/
config/
wsgi.py
settings/
__init__.py
local.py
production.py
base.py
app1/
app2/
谢谢!
答案 0 :(得分:0)
您是否尝试过更改
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "config.settings.production"
PYTHONPATH: "/opt/python/current/app/johngoben:$PYTHONPATH"
"ALLOWED_HOSTS": ".elasticbeanstalk.com"
"aws:elasticbeanstalk:container:python":
WSGIPath: site/config/wsgi.py
NumProcesses: 3
NumThreads: 20
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "www/static/"
到
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "project.config.settings.production"
PYTHONPATH: "/opt/python/current/app/johngoben:$PYTHONPATH"
"ALLOWED_HOSTS": ".elasticbeanstalk.com"
"aws:elasticbeanstalk:container:python":
WSGIPath: site/config/wsgi.py
NumProcesses: 3
NumThreads: 20
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "www/static/"