初次试用云托管,使用django模板做一个计数器,总是报错部署不了,为什么呢?
出现错误的地方如图: File "/root/.local/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/root/.local/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/root/.local/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/wxcloudrun/settings.py", line 73, in <module>
'HOST': os.environ.get("MYSQL_ADDRESS").split(':')[0],
AttributeError: 'NoneType' object has no attribute 'split'
检查了下对应的源代码 # Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ.get("MYSQL_DATABASE", 'django_demo'),
'USER': os.environ.get("MYSQL_USERNAME"),
'HOST': os.environ.get("MYSQL_ADDRESS").split(':')[0],
'PORT': os.environ.get("MYSQL_ADDRESS").split(':')[1],
'PASSWORD': os.environ.get("MYSQL_PASSWORD"),
'OPTIONS': {'charset': 'utf8mb4'},
}
}
问题可能就出在这里了 处理建议
尝试 重试
查看 服务日志
提交工单,并在 问题描述 中附上以下信息:环境id:prod-8gt1nmide947a7d5;服务名称:django-e640;版本:django-e640-006;状态:部署失败