简体   繁体   English

如何查看Django调试工具栏?

[英]How do I see the Django debug toolbar?

I have a Django webapp. 我有一个Django webapp。 I have installed the debug_toolbar middleware and module. 我已经安装了debug_toolbar中间件和模块。 However, my webapps don't have the debug toolbar pull-out. 但是,我的webapps没有调试工具栏拉出。

How do I actually see the debug toolbar? 我如何实际看到调试工具栏? Is there something more I need to do? 还有什么我需要做的吗? Do I need to use a particular template for my webapp? 我是否需要为我的webapp使用特定模板? I have followed all the steps in the README, but that is not enough -- there seems to be some other dependency, or something else I'm missing. 我已经按照自述文件中的所有步骤进行了操作,但这还不够 - 似乎还有一些其他依赖项,或者其他我缺少的东西。

Also, when looking at the set of URL patterns for my webapp, the debug prefix is not found among the recognized patterns. 此外,望着URL模式集合了我的web应用程序时, 调试前缀是认可的模式中找到。 I've put a log in urls.py in debug_toolbar to make sure that modules is getting loaded by the activated debug_toolbar application, and it is. 我在debug_toolbar中放入了一个urls.py日志,以确保激活的debug_toolbar应用程序正在加载模块,它就是。

This has me totally mystified, and I can find no Google or README on what to do to make this actually show up, or what the requirements are, so any pointer you can provide would be great! 这让我完全神秘,我找不到谷歌或自述文件来做这个实际显示,或者要求是什么,所以你能提供的任何指针都会很棒!

Edit: It turns out, I was testing this with a SSH tunnel from the machine running the browser to the machine running the Django/Apache. 编辑:事实证明,我正在使用SSH隧道从运行浏览器的机器到运行Django / Apache的机器进行测试。 In this case, the IP address actually seen for the remote machine was not what I thought it was, so the list of "good" IPs did not contain the browser's apparent remote machine. 在这种情况下,远程机器实际看到的IP地址不是我想象的那样,因此“好”IP列表不包含浏览器的明显远程机器。 Fixing that fixed the problem! 修复那个解决了问题!

  1. As I know your HTML page must contain closed body tag, meta tag with content="text/html" . 据我所知,您的HTML页面必须包含封闭的正文标记,元标记为content="text/html"

  2. I prefer the way when all debug-toolbar's settings separed from main settings. 我更喜欢所有调试工具栏的设置从主设置中分离出来的方式。 So try put in the end of settings.py something like 所以尝试把settings.py放在最后

     #debug_toolbar settings if DEBUG: INTERNAL_IPS = ('127.0.0.1',) MIDDLEWARE_CLASSES += ( 'debug_toolbar.middleware.DebugToolbarMiddleware', ) INSTALLED_APPS += ( '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', ] DEBUG_TOOLBAR_CONFIG = { 'INTERCEPT_REDIRECTS': False, } 

(Edit note: lapis updated the configs above to match the names used by the current (at the time of this update, 1.3.2) version of the Django Debug Toolbar. Per http://django-debug-toolbar.readthedocs.org/en/0.10.0/panels.html , the original versions (that used eg debug_toolbar.panels.sql.SQLDebugPanel vs debug_toolbar.panels.sql.SQLPanel as in 1.3.2) were correct when this question was original answered.) (编辑注释:lapis更新了上面的配置以匹配当前使用的名称(在本次更新时,1.3.2)Django调试工具栏的版本。根据http://django-debug-toolbar.readthedocs.org /en/0.10.0/panels.html ,原始版本(使用例如debug_toolbar.panels.sql.SQLDebugPanel vs debug_toolbar.panels.sql.SQLPanel,如1.3.2)在原始答案时是正确的。)

(note: after Django 1.10, MIDDLEWARE_CLASSES should be MIDDLEWARE .) (注意:在Django 1.10之后, MIDDLEWARE_CLASSES应该是MIDDLEWARE 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM