【发布时间】:2021-07-15 22:09:48
【问题描述】:
我正在构建 BlogApp,我正在尝试运行 Django-Debug-Toolbar 但它没有显示。我已经看到了很多答案,但对我没有任何帮助。
我已经按照Documentation正确安装了
我添加了installed apps、middlewares 和urls 以及collecstatic。但是当我转到浏览器时仍然没有显示。
settings.py
if DEBUG:
MIDDLEWARE += [
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
INSTALLED_APPS += [
'debug_toolbar',
]
INTERNAL_IPS = ['127.0.0.1', ]
# this is the main reason for not showing up the toolbar
import mimetypes
mimetypes.add_type("application/javascript", ".js", True)
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
}
urls.py
if settings.DEBUG:
import debug_toolbar
urlpatterns += [
path('__debug__/', include(debug_toolbar.urls)),
]
任何帮助将不胜感激。
提前致谢
【问题讨论】:
-
我可以想象两件事,首先,你能在你的项目中得到任何静态文件吗?可能
STATIC_URL配置不正确。第二个假设是DEBUG_TOOLBAR_CONFIG中的SHOW_TOOLBAR_CALLBACK变量,您能否将其更改为True? -
我也这样做了。但仍然没有显示。当我签入我的服务器时,它正在正确加载
debug_toolbar/css/toolbar.css。和static path is configured correctly. -
默认情况下,工具栏的 HTML 被注入到正文的末尾。如果您的模板不包含结束
</body>标记,它将不会被注入。
标签: python django debugging django-debug-toolbar