当我继续纠结于网站的性能的时候,我开始去寻找一切的办法,包括向作者寻问。最后作者告诉我可以试试用Django Debug Toolbar
。
The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel's content.
Django Debug Toolbar
D是一个可配置的组显示有关当前请求/响应和点击时的各种调试信息,显示有关面板的内容的更多详细信息面板。
看看官网截图
看上去似乎真的如传说中的一样强大,只是安装有点麻烦。。
1.安装Django Debug Toolbar
sudo pip install django-debug-toolbar
2.添加到INSTALLED_APPS
,添加
"debug_toolbar",
3.添加下行到MIDDLEWARE_CLASSES
,建议放到最后一行
'debug_toolbar.middleware.DebugToolbarMiddleware',
4.INTERNAL_IPS
设置,如果你和我一样已经放在服务器上了,就加上你的IP。
INTERNAL_IPS = ('127.0.0.1',)
5.不自动调整设置
DEBUG_TOOLBAR_PATCH_SETTINGS = False
6.添加到URLconf
from django.conf import settings
from django.conf.urls import include, patterns, url
if settings.DEBUG:
import debug_toolbar
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),
)
7.自定义工具栏
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',
]
最后效果如下所示
围观我的Github Idea墙, 也许,你会遇到心仪的项目