Django debugging tool-debug-toolbar installation tutorial

Source: Internet
Author: User
Tags install django pip install django
The Django debugging tool django-debug-toolbar installation and usage tutorials inevitably require debugging pages in website development. when using the django development site, you can use django-debug-toolbar for debugging, installing this plug-in is very useful. I first wanted to view all the context variable values on a page. of course, you can also see the HTTp header, Template, cache, and other information, in short, it is comprehensive and easy to use.

In the past, I used to install pycharm development in windows, deploy projects in virtual machines, and view the results in a local browser. this method may be a bit difficult for debugging, and django-debug-toolbar may appear, solved this problem.

The following describes how to install and use django-debug-toolbar:

1. install

Use commands

sudo pip install django-debug-toolbar

Install django-debug-toolbar. (Note that the Django version and debug_toolbar version are compatible. if there is no pip, install it first. for details, see The Tutorial: how to install python package manager pip)

2. configuration

In settings. py, add 'debug _ toolbar. middleware. DebugToolbarMiddleware 'to the MIDDLEWARE_CLASSES of the project.

Add INTERNAL_IPS = ('192. 0.0.1 ',) to settings. py)

Add 'debug _ Toolbar' to INSTALLED_APPS'

Make sure that the DEBUG option is true.

Add the DEBUG_TOOLBAR_PANELS option

Finally, set the template and add the template directory of debug_toolbar to TEMPLATE_DIRS.

The code is as follows:

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',]

All right, this is done. Note: If you have created a new site to test debug_tool, make sure to render a template so that the site has an accessible page. Otherwise, you cannot obtain the debug_tool interface.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.