0

我正在尝试安装django-debug-toolbar

每当我在设置中添加中间件时,我都会收到以下错误:

  File "<project_path>/.env/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
    self.load_middleware()
  File "<project_path>/.env/lib/python3.5/site-packages/django/core/handlers/base.py", line 82, in load_middleware
    mw_instance = middleware(handler)
TypeError: __init__() takes 1 positional argument but 2 were given

我的 settings.py 包含所有必要的东西:

INSTALLED_APPS = [
    #...
    'django.contrib.staticfiles',
    'debug_toolbar',
    #...

]
MIDDLEWARE = [
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    #....
    #....

]
MIDDLEWARE_CLASSES = [
    'debug_toolbar.middleware.DebugToolbarMiddleware',
]
4

2 回答 2

1

在 1.10 中,您必须升级django-debug-toolbar以支持MIDDLEWAREMIDDLEWARE_CLASSES

pip install django-debug-toolbar --upgrade
于 2016-10-16T07:52:09.557 回答
0

我必须升级这个答案django-debug-toolbar中提到的,然后在设置文件中添加一行:

INTERNAL_IPS = ('127.0.0.1')

使工具栏可见

于 2016-10-17T07:07:30.257 回答