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

    使用

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

  • 相关阅读:
    自定义异常
    异常的处理方式之二:声明异常(throws子句)
    异常的处理方式之一:捕获异常
    CheckedException已检查异常
    Range Sum Query
    cmd命令结束占用tomcat的进程
    原生js实现瀑布流
    js实现选项卡切换
    (转载)用ul做横向导航
    帝国CMS视频
  • 原文地址:https://www.cnblogs.com/leffss/p/11286535.html
Copyright © 2011-2022 走看看