简体   繁体   中英

Django: Internal Server Error

This is my first time deploying Django website on DigitalOcean and it causes me a lot of problems. I am using one click install, deployed my website from git and changed gunicorn and nginx files, but still it gives me

Internal Server Error.

Here is the Apache log:

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.

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 in MIDDLEWARE_CLASSES .

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.6

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' . The default settings.py created by django-admin.py startproject has SessionMiddleware activated.

If you don't want to use sessions, you might as well remove the SessionMiddleware line from MIDDLEWARE_CLASSES and 'django.contrib.sessions' from your INSTALLED_APPS . It'll save you a small bit of overhead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM