因爲系統限制,須要在django的邏輯代碼中設置系統環境變量.最開始使用
os.environ['環境變量名稱']='環境變量值'
卻一直都失敗(排除了這種方法在非django的python項目中是正常的).最開排查發現須要再django中設置才能夠.具體代碼以下:python
""" WSGI config for WorkPlatFormApi project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "WorkPlatFormApi.settings") os.environ.setdefault("GRPC_PROXY_USE_TLS", "0") os.environ.setdefault("GRPC_PROXY_PORT", "3333") os.environ.setdefault("GRPC_PROXY_HOST", "grpc-proxy.test.com") application = get_wsgi_application()