Django Debugging Tools Django-debug-toolbar Installation Tutorial

Source: Internet
Author: User
In the Web site development is inevitably to debug the page, while using the Django development site, you can use Django-debug-toolbar to debug, install this plugin is very useful, I started to look at a page of all the context variable values, of course, you can also see the HTTP header , templates, caches and other information, in short, very comprehensive and very useful.

Used to be used to install Pycharm development in Windows, the project is deployed in the virtual machine, in the local browser to see the effect, this way in debugging will be a bit of trouble, Django-debug-toolbar appear, solve the problem

Here's how to install and use Django-debug-toolbar:

1. Installation

Using commands

sudo pip install Django-debug-toolbar

Install Django-debug-toolbar. (Note the version compatibility issue with the Django version and Debug_toolbar, please install it without PIP, see Tutorial: Detailed Python Package manager pip installation)

2. Configuration

Add ' Debug_toolbar.middleware.DebugToolbarMiddleware ' to the project's middleware_classes within settings.py.

Add internal_ips = (' 127.0.0.1 ') in settings.py, (from which IP access site, show Debug_toolbar)

Add ' Debug_toolbar ' to Installed_apps

Ensure that the debug option is True

Add debug_toolbar_panels option

Finally set up the template, add debug_toolbar template directory 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 ',]

Well, the great job here has been gaocheng. Note that if you are creating a new site for testing Debug_tool, be sure to render a template so that the site has an accessible page, otherwise the Debug_tool interface is not available.

  • 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.