django- debug-toolbar配置

1.安装

pip install django-debug-toolbar

2.配置

步骤1:settings.py

INSTALLED_APPS中添加
'debug_toolbar.apps.DebugToolbarConfig'

MIDDLEWARE中添加
'debug_toolbar.middleware.DebugToolbarMiddleware'

文件尾部添加

INTERNAL_IPS = ('127.0.0.1',)
DEBUG_TOOLBAR_PATCH_SETTINGS = False
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保持开启

DEBUG = True
步骤2:urls.py

文件尾部添加

if settings.DEBUG:
    import debug_toolbar
    urlpatterns = urlpatterns+[url(r'^__debug__/',include(debug_toolbar.urls)),]

配置完毕

你可能感兴趣的:(django)