[英]Django: Internal Server Error
This is my first time deploying Django website on DigitalOcean and it causes me a lot of problems. 这是我第一次在DigitalOcean上部署Django网站,这给我带来了很多问题。 I am using one click install, deployed my website from git and changed gunicorn and nginx files, but still it gives me
我正在使用一键安装,从git部署了我的网站,并更改了gunicorn和nginx文件,但仍然可以给我
Internal Server Error.
Here is the Apache log: 这是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$
I can't really understand where the problem is and how to handle it. 我真的不明白问题在哪里以及如何解决。
According to the documentation : 根据文档 :
New in Django 1.7.
Django 1.7的新功能。
Allows a user's sessions to be invalidated when their password changes.
允许用户的会话在密码更改时失效。 See Session invalidation on password change for details.
有关详细信息,请参阅密码更改时的会话无效 。 This middleware must appear after
django.contrib.auth.middleware.AuthenticationMiddleware
inMIDDLEWARE_CLASSES
.该中间件必须出现在
MIDDLEWARE_CLASSES
django.contrib.auth.middleware.AuthenticationMiddleware
之后。
Thus, my guess is that you are not on Django 1.7+, yet you have defined the django.contrib.auth.middleware.SessionAuthenticationMiddleware
in the MIDDLEWARE_CLASSES
. 因此,我的猜测是您不是使用Django 1.7+,但您已经在
MIDDLEWARE_CLASSES
定义了django.contrib.auth.middleware.SessionAuthenticationMiddleware
。
See the Sessions Documentation . 请参阅会议文档 。
To enable session functionality, do the following:
要启用会话功能,请执行以下操作:
Edit the
MIDDLEWARE_CLASSES
setting and make sure it contains'django.contrib.sessions.middleware.SessionMiddleware'
.编辑
MIDDLEWARE_CLASSES
设置,并确保它包含'django.contrib.sessions.middleware.SessionMiddleware'
。 The default settings.py created by django-admin.py startproject has SessionMiddleware activated.django-admin.py startproject创建的默认settings.py已激活SessionMiddleware 。
If you don't want to use sessions, you might as well remove the SessionMiddleware line from
MIDDLEWARE_CLASSES
and'django.contrib.sessions'
from yourINSTALLED_APPS
.如果您不想使用会话,则最好从
MIDDLEWARE_CLASSES
删除SessionMiddleware行,并从INSTALLED_APPS
删除'django.contrib.sessions'
。 It'll save you a small bit of overhead.它将为您节省一点点开销。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.