我在无法显示我的网页的pythonanywhere上遇到此问题。我怀疑DJANGO_SETTINGS_MODULE有点问题,但我似乎无法使其正常工作。
也尝试使用“ Wagtail-Onepage-Portfolio.settings”,但也不起作用。
import os
import sys
path = '/home/webconexus/portfolio/portfolio/Wagtail-Onepage-Portfolio'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'portfolio.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
这是/var/www/www_rafrasenberg_nl_wsgi.py
Error running WSGI application
2019-02-06 14:58:00,884: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
2019-02-06 14:58:00,884: File "/var/www/www_rafrasenberg_nl_wsgi.py", line 12, in <module>
2019-02-06 14:58:00,884: application = get_wsgi_application()
2019-02-06 14:58:00,884:
2019-02-06 14:58:00,884: File "/home/webconexus/portfolio/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2019-02-06 14:58:00,884: django.setup(set_prefix=False)
2019-02-06 14:58:00,884:
2019-02-06 14:58:00,885: File "/home/webconexus/portfolio/lib/python3.7/site-packages/django/__init__.py", line 19, in setup
2019-02-06 14:58:00,885: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2019-02-06 14:58:00,885:
2019-02-06 14:58:00,885: File "/home/webconexus/portfolio/lib/python3.7/site-packages/django/conf/__init__.py", line 57, in __getattr__
2019-02-06 14:58:00,885: self._setup(name)
2019-02-06 14:58:00,885:
2019-02-06 14:58:00,885: File "/home/webconexus/portfolio/lib/python3.7/site-packages/django/conf/__init__.py", line 44, in _setup
2019-02-06 14:58:00,885: self._wrapped = Settings(settings_module)
2019-02-06 14:58:00,885:
2019-02-06 14:58:00,886: File "/home/webconexus/portfolio/lib/python3.7/site-packages/django/conf/__init__.py", line 126, in __init__
2019-02-06 14:58:00,886: raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
2019-02-06 14:58:00,886: ***************************************************
2019-02-06 14:58:00,886: If you're seeing an import error and don't know why,
2019-02-06 14:58:00,886: we have a dedicated help page to help you debug:
2019-02-06 14:58:00,886: https://help.pythonanywhere.com/pages/DebuggingImportError/
2019-02-06 14:58:00,886: ***************************************************
答案 0 :(得分:2)
错误消息对我来说很清楚。您的SECRET_KEY
字段(在应用程序的settings.py文件中)为空。您需要提供该设置的值(没有它,Django不会启动)。有关更多信息,请参见the docs。