zoukankan      html  css  js  c++  java
  • django-debug-toolbar的配置以及使用

    django-debug-toolbar的配置以及使用

    django 开中,用 django-debug-toolbar 来调试可以查看当前请求时间,sql,配置等信息,比较好用,安装过程也不复杂,本次使用环境为python3.7 + django2.2.3。

    安装

    pip install django-debug-toolbar

    配置

    vim settings.py 添加以下配置:

    INSTALLED_APPS = [
    	...
        'django.contrib.staticfiles',
        ...
        'debug_toolbar',
        ...
    ]
    ...
    MIDDLEWARE = [
        'debug_toolbar.middleware.DebugToolbarMiddleware',
        ...
    ]
    ...
    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',
        'debug_toolbar.panels.profiling.ProfilingPanel',
    ]
    INTERNAL_IPS = [
        # ...
        '127.0.0.1',
        # ...
    ]
    ...
    

    配置URL

    vim urls.py 添加以下配置:

    ...
    import debug_toolbar
    
    urlpatterns = [
        path('__debug__/', include(debug_toolbar.urls)),
        ...
    ]
    

    使用

    配置完成后重启启动服务器,每个页面都会添加一个调试侧边栏显示相关信息,具体使用方法不表。

  • 相关阅读:
    C++的命名空间的使用
    QT编译和运行ROS功能包
    Ubuntu安装Chromium浏览器
    回文字符串(LCS变形)
    友好城市(LIS+结构体排序)
    免费馅饼
    C++ STL之set学习笔记
    Coloring Contention
    Charles in Charge
    最短路之Floyd,Dijkstra(朴素+队列优化)
  • 原文地址:https://www.cnblogs.com/leffss/p/11286535.html
Copyright © 2011-2022 走看看