我正在将一个django应用程序从1.x移植到2.1,遇到了一个错误:“TypeError:object()不带参数”。我试图解决这个问题已经有一段时间了,但即使在网上调试和搜索了好几天之后,我仍然没有得到任何线索
已安装的应用程序:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.github',
'timezone_field',
'axes',
'humans',
'boxes',
'pages',
]
中间件设置:
MIDDLEWARE = [
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
]
压痕没有问题,
raven版本:6.9.0
django版本:2.1
import os
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
application=Sentry(get_wsgi_application())
下面是错误日志的摘录
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/app/wsgi.py", line 16, in <module>
application=Sentry(get_wsgi_application())
File "/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/wsgi.py", line 136, in __init__
self.load_middleware()
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 36, in load_middleware
mw_instance = middleware(handler)
TypeError: object() takes no parameters
in <module>
application = CustomSentry(get_wsgi_application())
File "/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/wsgi.py", line 136, in __init__
self.load_middleware()
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 36, in load_middleware
mw_instance = middleware(handler)
TypeError: object() takes no parameters
我尝试使用ExceptionMiddleware捕获异常,现在出现以下错误:
application = CustomSentry(get_wsgi_application())
File "/usr/local/lib/python3.5/dist-packages/django/utils/deprecation.py", line 85, in __init__
super().__init__()
TypeError: __init__() missing 1 required positional argument: 'application'