以下是我的配置:
SECRET_KEY = os.environ.get("SECRET_KEY", "0$ke!x1bz5cj0mpzo1zfx4omw-c9iqw%m95zb)(2@ddg5s+3!f")
ALLOWED_HOSTS = ['*']
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
# Application definition
INSTALLED_APPS = [
'posts', # Contains all dynamic and static pages related to posts
'courses', # Contains all dynamic and static pages related to courses and modules
'pages', # Contains all static pages that are not post related
'markdownx', # Allows for editing and creating markdown content
'jet.dashboard',
'jet', # Django admin theme override
'pwa', # Sets app to be PWA compliant
'whitenoise.runserver_nostatic', # Serving static files
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
我见过的每一个答案都说只需将ALLOWED_HOSTS设置为['*'],正如你所看到的,我已经这样做了,但仍然不行。我查看了文档,文档在DEBUG模式下还会影响哪些设置方面非常简略,其中有一节文档说道:
作为安全措施,Django不会包含可能敏感的设置,例如SECRET_KEY。具体而言,它将排除任何名称中包含以下任何内容的设置: 'API' 'KEY' 'PASS' 'SECRET' 'SIGNATURE' 'TOKEN'
https://docs.djangoproject.com/en/2.2/ref/settings/#debug
我能想到的唯一问题是 secret_key 没有被识别,但如果是这样,那么在生产环境中该怎么做呢?编辑:有些人要求我将调试模式设置为 true 以获取回溯信息。问题是,当我将其设置为 true 时,我不会收到 500 错误,只有在 DEBUG = False 时才会出现。
debug=True
并查看错误信息。如果不清楚,请在此处发布。 - Gábor Erdős系统检查未发现任何问题(0被静音)。 2019年12月14日 - 21:46:09 Django版本2.2.7,使用设置'canadiancoding.settings'在http://127.0.0.1:8000/上启动开发服务器/ 使用CTRL-BREAK退出服务器。 [14 / Dec / 2019 21:46:14]“GET / HTTP / 1.1”500 27
- Kieran Woodos.environ['SECRET_KEY']
时,输出是什么? - Debendra