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

    使用

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

  • 相关阅读:
    vue-cli之加载ico文件
    arcgisJs之featureLayer中feature的获取
    浏览器兼容设置
    global.css
    sass之mixin的全局引入(vue3.0)
    arcgis之隐藏设置放大缩小按钮
    vue之scoped穿透
    关闭google默认打开翻译提醒
    ...args剩余参数用法
    js之向div contenteditable光标位置添加字符
  • 原文地址:https://www.cnblogs.com/leffss/p/11286535.html
Copyright © 2011-2022 走看看