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.