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)),
        ...
    ]
    

    使用

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

  • 相关阅读:
    ArcGIS Server JavaScript API 各命名空间的含义【转】
    python datetime 转timestamp
    python re 里面match 和search的区别
    django 两种创建模型实例的方法
    delete old data in elasticsearch
    iptables做nat网络地址转换
    zabbix trapper items
    pssh远程执行命令的利器
    gentoo 下安装lamp
    xshell密钥登录服务器
  • 原文地址:https://www.cnblogs.com/leffss/p/11286535.html
Copyright © 2011-2022 走看看