{"id":193,"date":"2015-08-30T22:10:56","date_gmt":"2015-08-30T14:10:56","guid":{"rendered":"https:\/\/vinta.ws\/code\/?p=193"},"modified":"2026-03-17T01:20:37","modified_gmt":"2026-03-16T17:20:37","slug":"django-debug-toolbar","status":"publish","type":"post","link":"https:\/\/vinta.ws\/code\/django-debug-toolbar.html","title":{"rendered":"django-debug-toolbar: The Debugging Toolkit for Django"},"content":{"rendered":"<p>django-debug-toolbar is a toolset to display various debug information about the current request and response in Django.<\/p>\n<p>ref:<br \/>\n<a href=\"https:\/\/github.com\/django-debug-toolbar\/django-debug-toolbar\">https:\/\/github.com\/django-debug-toolbar\/django-debug-toolbar<\/a><\/p>\n<h2>Install<\/h2>\n<pre class=\"line-numbers\"><code class=\"language-bash\">$ pip install \n  django-debug-toolbar \n  django-debug-toolbar-line-profiler \n  django-debug-toolbar-template-profiler \n  django-debug-toolbar-template-timings \n  django-debug-panel \n  memcache-toolbar \n  pympler \n  git+https:\/\/github.com\/scuml\/debug-toolbar-mail<\/code><\/pre>\n<p>ref:<br \/>\n<a href=\"https:\/\/github.com\/dmclain\/django-debug-toolbar-line-profiler\">https:\/\/github.com\/dmclain\/django-debug-toolbar-line-profiler<\/a><br \/>\n<a href=\"https:\/\/github.com\/node13h\/django-debug-toolbar-template-profiler\">https:\/\/github.com\/node13h\/django-debug-toolbar-template-profiler<\/a><br \/>\n<a href=\"https:\/\/github.com\/orf\/django-debug-toolbar-template-timings\">https:\/\/github.com\/orf\/django-debug-toolbar-template-timings<\/a><br \/>\n<a href=\"https:\/\/github.com\/recamshak\/django-debug-panel\">https:\/\/github.com\/recamshak\/django-debug-panel<\/a><br \/>\n<a href=\"https:\/\/github.com\/ross\/memcache-debug-panel\">https:\/\/github.com\/ross\/memcache-debug-panel<\/a><br \/>\n<a href=\"https:\/\/pythonhosted.org\/Pympler\/django.html\">https:\/\/pythonhosted.org\/Pympler\/django.html<\/a><br \/>\n<a href=\"https:\/\/github.com\/scuml\/debug-toolbar-mail\">https:\/\/github.com\/scuml\/debug-toolbar-mail<\/a><\/p>\n<p>Python 3<br \/>\n<a href=\"https:\/\/github.com\/lerela\/django-debug-toolbar-line-profile\">https:\/\/github.com\/lerela\/django-debug-toolbar-line-profile<\/a><\/p>\n<h2>Configuration<\/h2>\n<p>in urls.py<\/p>\n<pre class=\"line-numbers\"><code class=\"language-py\">from django.conf import settings\nfrom django.conf.urls import include, url\n\nif settings.DEBUG:\n    import debug_toolbar\n    urlpatterns = [\n        url(r'^__debug__\/', include(debug_toolbar.urls)),\n    ] + urlpatterns<\/code><\/pre>\n<p>in settings.py<\/p>\n<pre class=\"line-numbers\"><code class=\"language-py\">INSTALLED_APPS += (\n    'debug_toolbar',\n    # 'debug_toolbar_line_profiler',\n    # 'memcache_toolbar',\n    # 'pympler',\n    # 'template_profiler_panel',\n    # 'template_timings_panel',\n)\nDEBUG_TOOLBAR_PANELS = [\n    # 'debug_toolbar.panels.versions.VersionsPanel',\n    # 'debug_toolbar.panels.timer.TimerPanel',\n    # 'debug_toolbar.panels.settings.SettingsPanel',\n    # 'debug_toolbar.panels.headers.HeadersPanel',\n    # 'debug_toolbar.panels.request.RequestPanel',\n    'debug_toolbar.panels.sql.SQLPanel',\n    # 'debug_toolbar.panels.staticfiles.StaticFilesPanel',\n    # 'debug_toolbar.panels.templates.TemplatesPanel',\n    # 'template_timings_panel.panels.TemplateTimings.TemplateTimings',\n    # 'template_profiler_panel.panels.template.TemplateProfilerPanel'\n    # 'debug_toolbar.panels.cache.CachePanel',\n    # 'memcache_toolbar.panels.memcache.MemcachePanel',\n    # 'debug_toolbar.panels.profiling.ProfilingPanel',\n    # 'debug_toolbar_line_profiler.panel.ProfilingPanel',\n    # 'pympler.panels.MemoryPanel',\n    # 'debug_toolbar.panels.signals.SignalsPanel',\n    # 'debug_toolbar.panels.logging.LoggingPanel',\n    # 'debug_toolbar.panels.redirects.RedirectsPanel',\n]\n\nif 'debug_toolbar' in INSTALLED_APPS:\n    MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)\n    MIDDLEWARE_CLASSES += [\n        'debug_toolbar.middleware.DebugToolbarMiddleware',\n    ]\n\ndef show_toolbar(request):\n    return True\n\nDEBUG_TOOLBAR_CONFIG = {\n    'SHOW_TOOLBAR_CALLBACK': show_toolbar,\n}\n\nINTERNAL_IPS = (\n    '127.0.0.1',\n)<\/code><\/pre>\n<p>ref:<br \/>\n<a href=\"http:\/\/django-debug-toolbar.readthedocs.org\/en\/latest\/configuration.html\">http:\/\/django-debug-toolbar.readthedocs.org\/en\/latest\/configuration.html<\/a><br \/>\n<a href=\"http:\/\/django-debug-toolbar.readthedocs.org\/en\/latest\/panels.html\">http:\/\/django-debug-toolbar.readthedocs.org\/en\/latest\/panels.html<\/a><\/p>\n<p>\u8981\u78ba\u4fdd\u6c92\u6709\u5728 <code>MIDDLEWARE_CLASSES<\/code> \u88e1\u555f\u7528\u4ee5\u4e0b\u7684 middlewares\uff1a<\/p>\n<ul>\n<li><code>&#039;django.middleware.gzip.GZipMiddleware&#039;<\/code><\/li>\n<li><code>&#039;django.middleware.http.ConditionalGetMiddleware&#039;<\/code><\/li>\n<\/ul>\n<p>ref:<br \/>\n<a href=\"http:\/\/django-debug-toolbar.readthedocs.io\/en\/stable\/installation.html#automatic-setup\">http:\/\/django-debug-toolbar.readthedocs.io\/en\/stable\/installation.html#automatic-setup<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>django-debug-toolbar is a toolbox to display various debug information about the current request and response in Django.<\/p>\n","protected":false},"author":1,"featured_media":778,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,116],"tags":[29,13,81,2],"class_list":["post-193","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-about-python","category-about-web-development","tag-debug","tag-django","tag-profiling","tag-python"],"_links":{"self":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts\/193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":0,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts\/193\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/media\/778"}],"wp:attachment":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}