[Django] Django-debug-Tools

Source: Internet
Author: User
Tags install django pip install django
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

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.