Django Debug Toolbar Only Working for Admin Section

岁酱吖の 提交于 2019-11-30 18:48:11

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

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' as last in the list of INSTALLED_APPS
  • Double check if the toolbar's assets are loaded
  • Make sure all toolbar settings are set. (DEBUG_TOOLBAR_CONFIG, INTERNAL_IPS) etc.

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. 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.

Missing INTERNAL_IPS key in settings.py impacts toolbar visibility. 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.

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,

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;
}

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!