首页 > 学院 > 开发设计 > 正文

[原]Django调试工具--django-debug-toolbar

2019-11-14 16:58:19
字体:
来源:转载
供稿:网友

请摒弃简单粗暴的PRint

                               --马云

我比较习惯在windows中安装pycharm开发,项目部署在虚拟机中,在本地浏览器中查看效果,这种方式在调试上会有点麻烦,django-debug-toolbar的出现,就解决了这个问题

一、步骤

  1. 使用sudo pip install django-debug-toolbar安装django-debug-toolbar。(注意Django版本和debug_toolbar的版本兼容问题)
  2. 在settings.py中添加'debug_toolbar.middleware.DebugToolbarMiddleware'到项目的MIDDLEWARE_CLASSES 内。
  3. 在settings.py中添加INTERNAL_IPS = ('127.0.0.1',),(从哪些ip访问站点,显示debug_toolbar)
  4. 在INSTALLED_APPS 中添加'debug_toolbar'
  5. 确保DEBUG选项为true
  6. 添加DEBUG_TOOLBAR_PANELS选项
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',]

最后的效果图:

更多信息请:django debug toolbar官方文档1.1版本 注意版本的兼容

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表