django debug toolbar使用简介,及docker中使用
来源:互联网 发布:淘宝网机器人 编辑:程序博客网 时间:2024/06/11 14:54
Installation
Getting the code
The recommended way to install the Debug Toolbar is via pip:
$ pip install django-debug-toolbar
If you aren’t familiar with pip, you may also obtain a copy of thedebug_toolbar
directory and add it to your Python path.
To test an upcoming release, you can install the in-development versioninstead with the following command:
$ pip install -e git+https://github.com/jazzband/django-debug-toolbar.git#egg=django-debug-toolbar
Prerequisites
Make sure that 'django.contrib.staticfiles'
isset up properly and add'debug_toolbar'
to yourINSTALLED_APPS
setting:
INSTALLED_APPS = [ # ... 'django.contrib.staticfiles', # ... 'debug_toolbar',]STATIC_URL = '/static/'
If you’re upgrading from a previous version, you should review thechange log and look for specific upgrade instructions.
URLconf
Add the Debug Toolbar’s URLs to your project’s URLconf as follows:
from django.conf import settingsfrom django.conf.urls import include, urlif settings.DEBUG: import debug_toolbar urlpatterns += [ url(r'^__debug__/', include(debug_toolbar.urls)), ]
This example uses the __debug__
prefix, but you can use any prefix thatdoesn’t clash with your application’s URLs. Note the lack of quotes arounddebug_toolbar.urls
.
Middleware
The Debug Toolbar is mostly implemented in a middleware. Enable it in yoursettings module as follows:
MIDDLEWARE = [ # ... 'debug_toolbar.middleware.DebugToolbarMiddleware', # ...]
Old-style middleware:
MIDDLEWARE_CLASSES = [ # ... 'debug_toolbar.middleware.DebugToolbarMiddleware', # ...]
Warning
The order of MIDDLEWARE
andMIDDLEWARE_CLASSES
is important. Youshould include the Debug Toolbar middleware as early as possible in thelist. However, it must come after any other middleware that encodes theresponse’s content, such asGZipMiddleware
.
Internal IPs
The Debug Toolbar is shown only if your IP is listed in the INTERNAL_IPS
setting. (You can change this logic with the SHOW_TOOLBAR_CALLBACK
option.) For local development, you should add '127.0.0.1'
toINTERNAL_IPS
.
USE IN DOCKER :
IP address that allowed me to display django toolbar was the IP of the getway associated with my docker container. To obtain IP of the gatway I run this comand
docker inspect my_container_name | grep -e '"Gateway"'# "Gateway": "172.18.0.1",
In total my settings look like this
INSTALLED_APPS = ( 'debug_toolbar',)INTERNAL_IPS = ['172.18.0.1']
- django debug toolbar使用简介,及docker中使用
- windows平台django-debug-toolbar使用Mark
- Django Debug Toolbar安装
- django-debug-tools 使用
- django-debug-toolbar-1.4在openstack horizon上的使用笔记
- ToolBar介绍及使用
- docker简介及使用国内镜像源安装docker
- 在Toolbar的使用简介
- ToolBar简介以及使用详解
- Django-- debug-toolbar的配置
- Debug 使用简介
- Debug 使用简介
- Debug 使用简介
- Dialog中使用Toolbar
- dialog中使用toolbar
- Dialog中使用Toolbar
- Fragment中使用Toolbar
- Fragment中使用toolbar
- Python时间戳和日期的相互转换
- 使用Maven 生成jar包的两种方式
- struts2 modeldriven
- Liunx 常用命令(三)
- excel向程序发送命令时出现问题
- django debug toolbar使用简介,及docker中使用
- iOS 10 适配 ATS
- CCNP-WLAN技术
- rsyslog imfile配置
- 最多约数问题
- JqGrid 异步分页
- Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition)
- 《数学之美》读书笔记(六)(七)(八)(九)
- bzoj2683