Django调试工具栏安装(Django 1.9)

Django debug toolbar installation (Django 1.9)

我在 virtualenv (Windows) 中使用 python 3.5.1 和 django 1.9.4。我正在尝试添加 django-debug-toolbar 但在启动服务器时出现错误。

我在 installed_apps 中添加了 'django_debug',在 middleware_classes 中添加了 'debug_toolbar.middleware.DebugToolbarMiddleware'。

Pip 冻结日志:

Django==1.9.4
django-debug-toolbar==1.4
sqlparse==0.1.19

运行服务器:

ImportError: 没有名为 'django_debug'

的模块

您必须在 INSTALLED_APPS 中添加 debug_toolbar 而不是 django_debug.

此外,您可以删除在 MIDDLEWARE_CLASSES 中添加的 class。正如文档中给出的那样:

If MIDDLEWARE_CLASSES doesn’t contain the middleware, the Debug Toolbar automatically adds it the beginning of the list.

你可以看看docs

首先安装 django-debug-toolbar,方法是:

 pip3 install django-debug-toolbar (pip3 since you're using python3),

接下来在您的 INSTALLED_APPS 添加:

'debug_toolbar'

而不是 django_debug,并且还删除了您添加的中间件(不确定,因为我从未添加过)。