$ pip install django-debug-toolbar
$ vim settings.py
""
INSTALLED_APPS += (
'debug_toolbar',
'debug_test',
)
MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
""
$ vim settings.py
""
CONFIG_DEFAULTS = {
# 因为默认使用google的jquery,国内访问不到
'JQUERY_URL': '//cdn.bootcss.com/jquery/2.1.4/jquery.min.js',
}
# 这些请求地址显示debug toolbar(注:后面的2个地址是我本地请求地址)
INTERNAL_IPS = (
"127.0.0.1", "192.168.33.11", "191.168.56.1", "192.168.33.1"
)
""
创建一个debug_test app,架构如下:
debug_test
- __init__.py
- templates
- debug.html
views.py
views.py内容:
# -*- coding: utf-8 -*-
from django.shortcuts import render
def debug_view(request):
"""
测试使用
:param request:
:return:
"""
from resource_ccnu.rs_paper.utils import PaperFactory
paper_id = 'Cj09A_KMCJ6-220170816'
PaperFactory().save(
'copy',
paper_id=paper_id
)
return render(request, "debug.html", locals())
if settings.DEBUG:
import debug_toolbar
from debug_test.views import debug_view
urlpatterns = [
url(r'^__debug__/', include(debug_toolbar.urls)),
url(r'^debug_view$', debug_view),
] + urlpatterns
$ vim lib/python2.7/site-packages/debug_toolbar/settings.py