@breakerthb
2016-10-21T07:17:07.000000Z
字数 1105
阅读 2456
Django
$ sudo pip install django-debug-toolbar
安装django-debug-toolbar。(注意Django版本和debug_toolbar的版本兼容问题,没有pip请先安装,参见教程:详解python包管理器pip安装 )
settings.py
添加DEBUG_TOOLBAR_PANELS选项
最后设置模板,添加debug_toolbar的模板目录到TEMPLATE_DIRS。
代码如下:
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',
]
好了,到这里大功即已告成。注意,如果你是为了测试debug_tool创建了一个新的站点,务必要渲染一个模板,让站点有一个可以访问的页面,否 则是得不到debug_tool的界面的。