[英]Django: Internal Server Error
這是我第一次在DigitalOcean上部署Django網站,這給我帶來了很多問題。 我正在使用一鍵安裝,從git部署了我的網站,並更改了gunicorn和nginx文件,但仍然可以給我
Internal Server Error.
這是Apache日志:
2015-05-18 15:24:08 [20726] [ERROR] Error handling request Traceback
(most recent call last): File
"/usr/lib/python2.7/dist-packages/gunicorn/workers/async.py", line
45, in handle
self.handle_request(listener, req, client, addr) File "/usr/lib/python2.7/dist-packages/gunicorn/workers/ggevent.py", line
119, in handle_r$
super(GeventWorker, self).handle_request(*args) File "/usr/lib/python2.7/dist-packages/gunicorn/workers/async.py", line
93, in handle_requ$
respiter = self.wsgi(environ, resp.start_response) File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line
187, in __call__
self.load_middleware() File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line
45, in load_mid$
mw_class = import_by_path(middleware_path) File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py",
line 31, in import$
error_prefix, module_path, class_name)) ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a
"SessionAuth$
我真的不明白問題在哪里以及如何解決。
根據文檔 :
Django 1.7的新功能。
允許用戶的會話在密碼更改時失效。 有關詳細信息,請參閱密碼更改時的會話無效 。 該中間件必須出現在
MIDDLEWARE_CLASSES
django.contrib.auth.middleware.AuthenticationMiddleware
之后。
因此,我的猜測是您不是使用Django 1.7+,但您已經在MIDDLEWARE_CLASSES
定義了django.contrib.auth.middleware.SessionAuthenticationMiddleware
。
請參閱會議文檔 。
要啟用會話功能,請執行以下操作:
編輯
MIDDLEWARE_CLASSES
設置,並確保它包含'django.contrib.sessions.middleware.SessionMiddleware'
。 django-admin.py startproject創建的默認settings.py已激活SessionMiddleware 。如果您不想使用會話,則最好從
MIDDLEWARE_CLASSES
刪除SessionMiddleware行,並從INSTALLED_APPS
刪除'django.contrib.sessions'
。 它將為您節省一點點開銷。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.