标签:bar request temp 完成 pat install panel ddl red
django 开中,用 django-debug-toolbar 来调试可以查看当前请求时间,sql,配置等信息,比较好用,安装过程也不复杂,本次使用环境为python3.7 + django2.2.3。
pip install django-debug-toolbar
vim settings.py 添加以下配置:
INSTALLED_APPS = [
...
'django.contrib.staticfiles',
...
'debug_toolbar',
...
]
...
MIDDLEWARE = [
'debug_toolbar.middleware.DebugToolbarMiddleware',
...
]
...
DEBUG_TOOLBAR_PANELS = [
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels.headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
'debug_toolbar.panels.sql.SQLPanel',
'debug_toolbar.panels.staticfiles.StaticFilesPanel',
'debug_toolbar.panels.templates.TemplatesPanel',
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging.LoggingPanel',
'debug_toolbar.panels.redirects.RedirectsPanel',
'debug_toolbar.panels.profiling.ProfilingPanel',
]
INTERNAL_IPS = [
# ...
'127.0.0.1',
# ...
]
...
vim urls.py 添加以下配置:
...
import debug_toolbar
urlpatterns = [
path('__debug__/', include(debug_toolbar.urls)),
...
]
配置完成后重启启动服务器,每个页面都会添加一个调试侧边栏显示相关信息,具体使用方法不表。
标签:bar request temp 完成 pat install panel ddl red
原文地址:https://www.cnblogs.com/leffss/p/11286535.html