django添加debug_toolbar作调试工具

django最大的问题就是版本太多,网上的教程很多分不清版本

django 1.10,python3.6

1.pip install debug_toolbar,安装完成

2.setting.py

INSTALLED_APPS = [
#.......
    'django.contrib.staticfiles',
    'debug_toolbar', 
# ......
]

MIDDLEWARE = [
#......
    'debug_toolbar.middleware.DebugToolbarMiddleware',
]

STATIC_URL = '/static/'
INTERNAL_IPS = ('127.0.0.1',)
DEBUG_TOOLBAR_CONFIG = {  'JQUERY_URL' : r"http://code.jquery.com/jquery-2.1.1.min.js"}

3.url.py

from django.conf.urls.static import static
from django.conf import settings

if settings.DEBUG:
    import debug_toolbar
    urlpatterns += [
        url(r'^__debug__/', include(debug_toolbar.urls)),
    ]

应该可以用了。

 

原始文档:

http://django-debug-toolbar.readthedocs.io/en/1.3/installation.html#quick-setup

Quick setup

Make sure that 'django.contrib.staticfiles' is set up properly and add 'debug_toolbar' to yourINSTALLED_APPS setting:

INSTALLED_APPS = (
    # ...
    'django.contrib.staticfiles',
    # ...
    'debug_toolbar',
)

STATIC_URL = '/static/'

For a simple Django project, that’s all you need!

The Debug Toolbar will automatically adjust a few settings when you start the development server, provided the DEBUG setting is True.

If you’re upgrading from a previous version, you should review the change log and look for specific upgrade instructions.

If the automatic setup doesn’t work for your project, if you want to learn what it does, or if you prefer defining your settings explicitly, read below.

木易的技术记录 » django添加debug_toolbar作调试工具

顶 (0)

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

置顶文章