Use Django-debug-Tools
It is very easy to develop with Django, but many times our experience is not enough, we will dig a lot of traps for ourselves, whether it is performance problems, or the use of development language skills will pose a threat to the stability of the application. After development, debugging and optimization become very important, today, we will try to use Django-debug-toolbar to add more debugging and monitoring for our development. I have heard of it before, but I have never applied it.
Here is python1.6. The configuration of 1.7 is slightly changed. For more information, see the document.
Install
Install using Pip
pip install django-debug-toolbar
Reference address
Configure basic configurations
Modify the configuration in settings. py
Add an app and installed_apps
INSTALLED_APPS = ( # ... ‘django.contrib.staticfiles‘, # ... # If you‘re using Django 1.7.x or later ‘debug_toolbar.apps.DebugToolbarConfig‘, # If you‘re using Django 1.6.x or earlier ‘debug_toolbar‘,)
Also set to debug mode
DEBUG = True
This configuration method can be used by runserver, but more configuration is required for other startup methods. For more information, see
There are also some advanced custom configuration.
More detailed configurations
Use
Here we use the default configuration
Start the Django development server. Entering the project
An icon is displayed on the top of the browser, for example:
Click the icon to view some debug options, such.
Let's check the SQL Execution (). We can see the total SQL Execution time, the number of SQL statements, the execution time of each SQL statement, and the SQL statement. Still very detailed.
Summary
From the trial perspective, the debug-tool is still very powerful, which brings many aspects to our development and debugging.
Jquery Configuration
When I used it today, I found that the default jquery configuration in it is Google's CDN. For f reasons, we configured a non-foreign source in settings.
DEBUG_TOOLBAR_CONFIG = { ‘JQUERY_URL‘ : "http://code.jquery.com/jquery-2.1.1.min.js"}
In this way, you can use it normally.
This article from the "orangleliu notebook" blog, reprint please be sure to keep this source http://blog.csdn.net/orangleliu/article/details/40431785
[Django] Django-debug-Tools