简体   繁体   English

Django 调试工具栏仅适用于管理部分

[英]Django Debug Toolbar Only Working for Admin Section

Hey, I've been using Django 1.2.1 for some time now and came across Django Debug Toolbar just the other day.嘿,我已经使用 Django 1.2.1 一段时间了,前几天遇到了 Django 调试工具栏。 It looks really useful and I'm really eager to try some stuff out.它看起来非常有用,我真的很想尝试一些东西。

I installed exactly how the readme said.我完全按照自述文件说的安装了。 Step by Step.一步步。 I put the middleware at the end just in case things get caught up but I'm using quite standard middleware (common, sessions, auth and csrf).我把中间件放在最后以防万一出现问题,但我使用的是非常标准的中间件(common、session、auth 和 csrf)。 However, it won't show up on any of my pages.但是,它不会出现在我的任何页面上。 I've tried moving the middleware but to the same effect.我试过移动中间件,但效果相同。

It seems as if I've installed something wrong.好像我安装了错误的东西。 But, when I load up the Admin Section of django, the toolbar springs up.但是,当我加载 django 的管理部分时,工具栏会弹出。 I'm not sure what I'm doing wrong.我不确定我做错了什么。 Can the content of my pages effect the toolbar coming up?我的页面内容会影响工具栏的出现吗? It's outputting in the mime text/html...它在 mime text/html 中输出...

Anyway, any help is greatly appreciated.无论如何,非常感谢任何帮助。 Thanks in advance.提前致谢。

Here's my Settings.py: pastebin.com/Hu8TgANt这是我的 Settings.py:pastebin.com/Hu8TgANt

Debug toolbar requires that there's at least a closing </body> tag in the response HTML.调试工具栏要求响应 HTML 中至少有一个结束</body>标记。

This tag can be changed by changing settings.DEBUG_TOOLBAR_CONFIG['INSERT_BEFORE']可以通过更改settings.DEBUG_TOOLBAR_CONFIG['INSERT_BEFORE']来更改此标签settings.DEBUG_TOOLBAR_CONFIG['INSERT_BEFORE']

http://django-debug-toolbar.readthedocs.org/en/latest/configuration.html#toolbar-options http://django-debug-toolbar.readthedocs.org/en/latest/configuration.html#toolbar-options

A few tipps without knowing your code:一些不知道你的代码的提示:

  • 'debug_toolbar.middleware.DebugToolbarMiddleware' should be your last or second to last middle ware entry (not 100% sure how it works out with the flatpagefallback middleware) 'debug_toolbar.middleware.DebugToolbarMiddleware' 应该是你的最后一个或倒数第二个中间件条目(不是 100% 确定它如何与 flatpagefallback 中间件一起工作)
  • 'debug-toolbar' as last in the list of INSTALLED_APPS “调试工具栏”作为 INSTALLED_APPS 列表中的最后一个
  • Double check if the toolbar's assets are loaded仔细检查工具栏的资产是否已加载
  • Make sure all toolbar settings are set.确保设置了所有工具栏设置。 (DEBUG_TOOLBAR_CONFIG, INTERNAL_IPS) etc. (DEBUG_TOOLBAR_​​CONFIG, INTERNAL_IPS) 等。

The error should be something in there.错误应该在那里。 I know of other problems related getting the toolbar displayed on flatpages so if you only checked on flatpages I suggest you try it on another module.我知道与在平面页面上显示工具栏相关的其他问题,所以如果您只检查平面页面,我建议您在另一个模块上尝试。

I had the same problem here, and eventually arrived at this post... Anyway, in my case what I noticed was that I had a javascript error in one of my js included libraries.我在这里遇到了同样的问题,最终到达了这篇文章......无论如何,就我而言,我注意到我的一个包含 js 的库中有一个 javascript 错误。 And that breaked the js interpretation flow.这打破了 js 解释流程。 When I fixed the javascript error, the django toolbar worked.当我修复 javascript 错误时,django 工具栏起作用了。

That explains why it worked in the admin pages, but not in my app pages.这解释了为什么它在管理页面中有效,但在我的应用程序页面中无效。

Missing INTERNAL_IPS key in settings.py impacts toolbar visibility. settings.py 中缺少 INTERNAL_IPS 键会影响工具栏的可见性。 Adding this resolves the issue:添加这个可以解决这个问题:

INTERNAL_IPS = ('127.0.0.1',)

I had a similar issue.我有一个类似的问题。 The solution was closing a div as a non-empty HTML element.解决方案是将 div 作为非空 HTML 元素关闭。

From this由此

<body>
...
    <div id="map-canvas"/>
...
</body>

to this对此

<body>
...
    <div id="map-canvas"></div>
...
</body>

Hope it helps!希望能帮助到你!

In my case, I was using Google Material Design Lite as the frontend framework,就我而言,我使用 Google Material Design Lite 作为前端框架,

which has the style definition,具有样式定义,

*[hidden]{
    display:none!important;
}

this style is applied to Debug Toolbar's elements which result in displaying nothing.此样式应用于调试工具栏的元素,导致不显示任何内容。

a quick workaround was to change the MDL's style definition (only possible on local stylesheets, not with cdn hosted) to一个快速的解决方法是将 MDL 的样式定义(仅适用于本地样式表,不适用于 CDN 托管)更改为

*[hidden]{
    display:none;
}

In my case the error was very simple.就我而言,错误非常简单。

I removed the footer and it worked like a charm!我删除了页脚,它就像一个魅力!

Hope this solves an issue for somebody else.希望这可以解决其他人的问题。

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

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