Django Debug Toolbar Only Working for Admin Sectio

2019-02-12 23:12发布

Hey, I've been using Django 1.2.1 for some time now and came across Django Debug Toolbar just the other day. 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). 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. 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...

Anyway, any help is greatly appreciated. Thanks in advance.

Here's my Settings.py: pastebin.com/Hu8TgANt

7条回答
▲ chillily
2楼-- · 2019-02-12 23:47

I had a similar issue. The solution was closing a div as a non-empty HTML element.

From this

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

to this

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

Hope it helps!

查看更多
forever°为你锁心
3楼-- · 2019-02-12 23:59

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. And that breaked the js interpretation flow. When I fixed the javascript error, the django toolbar worked.

That explains why it worked in the admin pages, but not in my app pages.

查看更多
叛逆
4楼-- · 2019-02-13 00:01

Missing INTERNAL_IPS key in settings.py impacts toolbar visibility. Adding this resolves the issue:

INTERNAL_IPS = ('127.0.0.1',)
查看更多
霸刀☆藐视天下
5楼-- · 2019-02-13 00:02

In my case, I was using Google Material Design Lite as the frontend framework,

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

*[hidden]{
    display:none;
}
查看更多
Viruses.
6楼-- · 2019-02-13 00:04

Debug toolbar requires that there's at least a closing </body> tag in the response HTML.

This tag can be changed by changing settings.DEBUG_TOOLBAR_CONFIG['INSERT_BEFORE']

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

查看更多
兄弟一词,经得起流年.
7楼-- · 2019-02-13 00:06

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.

查看更多
登录 后发表回答