我在部署我的第一個 Django 專案時遇到問題。
這是我的config.yml:
global:
application_name: testapp
branch: null
default_ec2_keyname: aws-eb
default_platform: Python 3.8 running on 64bit Amazon Linux 2
default_region: us-west-2
include_git_submodules: true
instance_profile: null
platform_name: null
platform_version: null
profile: eb-cli
repository: null
sc: null
workspace_type: Application
這是我的django.config:
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: djangoproject.wsgi:application
我已經關注了這個檔案。但是在我這樣做之后eb create testapp-env,我收到了 502 錯誤:錯誤
影像
如果您需要,我會提供更多資訊。預先感謝您的幫助。
這是錯誤web.stdout.log:
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
更新
我的 django 專案使用 python-socketio,這是我的 wsgi.py:
from django.core.wsgi import get_wsgi_application
import socketio
from post.socketioserver import sio # <- it's just my socket io code
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoproject.settings')
django_app = get_wsgi_application()
application = socketio.WSGIApp(sio, django_app)
我收到另一個錯誤:
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
uj5u.com熱心網友回復:
您需要設定DJANGO_SETTINGS_MODULE環境變數:
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: djangoproject.wsgi:application
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: "djangoproject.settings"
您還需要編輯您的wsgi.py檔案,因為您在 Django 設定之前訪問了一個應用程式:
import django
django.setup()
from django.core.wsgi import get_wsgi_application
import socketio
from post.socketioserver import sio # <- it's just my socket io code
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoproject.settings')
django_app = get_wsgi_application()
application = socketio.WSGIApp(sio, django_app)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/373687.html
上一篇:如何使用ClassicLoadBalancer配置ElasticBeanstalkNodeJS應用程式以使用HTTPS?
