从1.11升级到2.0后,Django wsgi错误(load_middleware:reversed()的参数必须是一个序列)

时间:2018-10-29 13:19:50

标签: django mod-wsgi django-2.0 django-middleware django-wsgi

从Django 1.11升级到2.0后,我的生产机上出现此错误。

 mod_wsgi (pid=26504): Target WSGI script '/var/www/htdocs/myappdir/app_myapp.wsgi' cannot be loaded as Python module.
 mod_wsgi (pid=26504): Exception occurred processing WSGI script '/var/www/htdocs/myappdir/app_myapp.wsgi'.
 Traceback (most recent call last):
   File "/var/www/htdocs/myappdir/app_myapp.wsgi", line 13, in <module>
     application = django.core.wsgi.get_wsgi_application()
   File "/var/www/priv/venv/myappdirpy3/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
     return WSGIHandler()
   File "/var/www/priv/venv/myappdirpy3/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 140, in __init__
     self.load_middleware()
   File "/var/www/priv/venv/myappdirpy3/lib/python3.5/site-packages/django/core/handlers/base.py", line 36, in load_middleware
     for middleware_path in reversed(settings.MIDDLEWARE):
 TypeError: argument to reversed() must be a sequence

settings.MIDDLEWARE选项似乎有问题,但看起来是正确的。这是我的settings.py

中的MIDDLEWARE部分
MIDDLEWARE = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
    'wagtail.core.middleware.SiteMiddleware',
    'wagtail.contrib.redirects.middleware.RedirectMiddleware',
]

如果我直接在生产机上运行“ python3 manage.py runserver”,则一切似乎都可以正常工作。但是,如果我通过wsgi访问该程序,它将无法正常工作。

任何想法从哪里开始?

0 个答案:

没有答案