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.