在此处输入图像描述
我想显示调试工具栏,但它看起来像上面一样。。怎么了?
首先,确保INSTALLED_APPS(settings.py(中有"django.contrib.staticfiles">
INSTALLED_APPS = [
# ...
"django.contrib.staticfiles",
# ...
]
STATIC_URL = "static/"
检查您是否有";django.template.backends.django.DjanoTemplates"以及";APP_DIRS":在settings.py 内的模板配置中为True
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
# ...
}
]
添加";调试工具栏";到您的INSTALLED_APPS设置.py
INSTALLED_APPS = [
# ...
"debug_toolbar",
# ...
]
将django调试工具栏的url添加到项目的URLconf[URLs.py,或任何url文件:(]
from django.urls import include, path
urlpatterns = [
# ...
path('__debug__/', include('debug_toolbar.urls')),
]
添加中间件(settings.py(
MIDDLEWARE = [
# ...
"debug_toolbar.middleware.DebugToolbarMiddleware",
# ...
]
配置内部IP将此配置添加到settings.py
INTERNAL_IPS = [
# ...
"127.0.0.1",
# ...
]
现在应该工作了;(
更多信息https://django-debug-toolbar.readthedocs.io/en/latest/installation.html