


Django debugging tool django-debug-toolbar installation and usage tutorial
In website development, it is inevitable to debug the page. When using django to develop the site, you can use django-debug-toolbar for debugging. Installing this plug-in is very useful. I initially wanted to view all the context variable values in a certain page. Of course, you can also see various information such as HTTP headers, templates, caches, etc. In short, it is very comprehensive and easy to use.
In the past, I was more accustomed to installing pycharm in Windows for development. The project was deployed in a virtual machine and the effect was viewed in a local browser. This method would be a bit troublesome in debugging. The emergence of django-debug-toolbar solved this problem.
Here's how to install and use django-debug-toolbar:
1. Install
Use the command
sudo pip install django-debug-toolbar
Install django-debug-toolbar. (Note that Django version and debug_toolbar version are compatible. If you don’t have pip, please install it first. See tutorial: Detailed explanation of python package manager pip installation)
2. 配置
Add 'debug_toolbar.middleware.DebugToolbarMiddleware' to the project in settings.py within MIDDLEWARE_CLASSES.
Add INTERNAL_IPS = ('127.0.0.1',) in settings.py, (from which ip to access the site, show debug_toolbar)
Add 'debug_toolbar' in INSTALLED_APPS
Make sure the DEBUG option is true
Add 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', ]
Okay, you are done here. Note that if you create a new site for testing debug_tool, be sure to render a template so that the site has an accessible page, otherwise you will not get the debug_tool interface.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

How to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...

When using Python's pandas library, how to copy whole columns between two DataFrames with different structures is a common problem. Suppose we have two Dats...

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...

How does Uvicorn continuously listen for HTTP requests? Uvicorn is a lightweight web server based on ASGI. One of its core functions is to listen for HTTP requests and proceed...

In Python, how to dynamically create an object through a string and call its methods? This is a common programming requirement, especially if it needs to be configured or run...

Using python in Linux terminal...

Understanding the anti-crawling strategy of Investing.com Many people often try to crawl news data from Investing.com (https://cn.investing.com/news/latest-news)...
