Django 调试工具栏安装问题
我在尝试启动并运行 django-debug-toolbar 时遇到问题。我已将所有必要的信息添加到 INSTALLED_APPS
、MIDDLEWARE_CLASSES
中,并且我的 IP 位于 INTERNAL_IPS
元组中。我已经运行了 setup.py 脚本,一切似乎都加载得很好,因为我没有从 django 或 apache 收到任何错误。
但是,没有任何反应 - 任何页面上都没有工具栏,有其他人见过这种行为吗?我错过了一些明显的东西吗?
I am having issues trying to get the django-debug-toolbar up and running. I have all of the necessary info added to INSTALLED_APPS
, MIDDLEWARE_CLASSES
, and my ip is in the INTERNAL_IPS
tuple. I have run the setup.py script and everything seems to load fine as I am getting no errors from django or apache.
However, nothing happens - no toolbar on any pages, has anyone else ever seen this behavior? Am I missing something obvious?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有一段时间也遇到过同样的问题。
您是否尝试过登录管理面板?如果工具栏显示在那里,但未显示在您的代码中,则很可能您缺少模板中的开始和结束标记。默认情况下,django 调试工具栏附加到 BODY 标记,但您可以根据需要更改此行为。请参阅此问题:Django 调试工具栏仅适用于管理部分
I had this same issue for awhile.
Have you tried logging into the admin panel? If the toolbar displays there, but does not display in your code, it's very likely that you are missing the opening and closing tags in your template. By default, django debug toolbar attaches to the BODY tag, though you can change this behavior if you desire. See this question: Django Debug Toolbar Only Working for Admin Section
我要么做两件事之一:
insert import pdb; pdb.set_trace() 在中间件
_show_toolbar
方法中,查看它在哪个项目上失败,或者在中间件中添加打印语句以查看它在哪个检查上失败,无论您更喜欢哪个和。I'd either do one of 2 things:
insert
import pdb; pdb.set_trace()
at the middleware_show_toolbar
method and see which item it fails on, or pepper the middleware with print statements to see which check it failed on, whichever you're more comfortable with.