django-debug-toolbar

django-debug-toolbar 调试工具使用文档

安装

1
pip install django-debug-toolbar

配置

settings.py文件中添加配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
INSTALLED_APPS = [
# ...
'django.contrib.staticfiles',
# ...
'debug_toolbar',
]

STATIC_URL = '/static/'

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

INTERNAL_IPS = [
'127.0.0.1',
]

# 添加debug-toolbar的中间件
DEBUG_TOOLBAR_PANELS = [
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels.headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
'debug_toolbar.panels.sql.SQLPanel',
'debug_toolbar.panels.staticfiles.StaticFilesPanel',
'debug_toolbar.panels.templates.TemplatesPanel',
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging.LoggingPanel',
'debug_toolbar.panels.redirects.RedirectsPanel',
]

urls.py中添加内容

1
2
3
4
5
if settings.DEBUG:
import debug_toolbar
urlpatterns = [
url(r'^debug/', include(debug_toolbar.urls)),
] + urlpatterns

配置完成,启动项目即可。

参考文档:官方文档

感谢您的支持!学如逆水行舟,不进则退!