Django exception middleware: TypeError: object() takes no parameters

3380 단어
jiango를 업그레이드하는 과정에서 settings를 수정합니다.py 이후 전체 오류 메시지는 다음과 같습니다.
Unhandled exception in thread started by .wrapper at 0x10fa4a840>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 140, in inner_run
    handler = self.get_handler(*args, **options)
  File "/usr/local/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
    handler = super().get_handler(*args, **options)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 65, in get_handler
    return get_internal_wsgi_application()
  File "/usr/local/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 44, in get_internal_wsgi_application
    return import_string(app_path)
  File "/usr/local/lib/python3.6/site-packages/django/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in _call_with_frames_removed
  File "/Users/fukainan/Desktop/jiango-blank/webapp/wsgi.py", line 16, in 
    application = get_wsgi_application()
  File "/usr/local/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    return WSGIHandler()
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 140, in __init__
    self.load_middleware()
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 39, in load_middleware
    mw_instance = middleware(handler)
TypeError: object() takes no parameters

오류 정보를 보려면middleware에 오류가 있습니다.Stackoverflow를 찾았는데 Django의 새 버전이 사용자 정의middleware의 쓰기 방식을 변경했습니다.https://docs.djangoproject.com/en/1.10/topics/http/middleware/#upgrading-pre-django-1-10-style-middleware 하지만settings.py에서 사용자 정의middleware를 사용하지 않았습니다. 다음과 같습니다.
MIDDLEWARE = [
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
]

settings에서.py에서 middleware를 찾으면 다음 코드가 표시됩니다.
if DEBUG:
    MIDDLEWARE = list(MIDDLEWARE)
    MIDDLEWARE.append('jiango.debug.middleware.SQLDebugMiddleware')

SQLDebugMiddleware를 변경하면 문제가 해결됩니다.

좋은 웹페이지 즐겨찾기