Djano调试工具debug-toolbar

Djano调试工具debug-toolbar

 

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

安装


pip install django-debug-toolbar

配置

settings.py文件中添加配置:


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中添加内容


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

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

参考文档:官方文档

 
posted @ 2019-03-02 13:50  小学弟-  阅读(176)  评论(0编辑  收藏  举报