django-debug-toolbar是django调试神器,对于edx开发助益极大,当前edx birch中集成的django-debug-toolbar版本是0.1.10,不支持缓存展示。

为了调试缓存,想升级django-debug-toolbar,其仓库首页说,当前版本是1.3.2,支持django 1.4 到 1.8。于是在edx中安装新的django-debug-toolbar。切换到edxapp,之后uninstall旧的,最后pip install django-debug-toolbar==1.3.2.搞定。

新旧版的django-debug-toolbar参数有些不同.需要做微调,具体可以参考文档.其中更多的可选panel可以参考这里

我有时候会在夜深人静的时候直接调试真实线上环境(恶劣的习惯!),我们需要临时对aws.py做些临时修改

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
DEBUG = True
TEMPLATE_DEBUG = True
################################ DEBUG TOOLBAR ################################

INSTALLED_APPS += ('debug_toolbar','debug_toolbar_mongo',) #'memcache_toolbar'

MIDDLEWARE_CLASSES += ('django_comment_client.utils.QueryCountDebugMiddleware',
                       'debug_toolbar.middleware.DebugToolbarMiddleware',)
INTERNAL_IPS = ('127.0.0.1',)

DEBUG_TOOLBAR_PANELS = (
    'debug_toolbar.panels.version.VersionDebugPanel',
    'debug_toolbar.panels.timer.TimerDebugPanel',
    #'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
    'debug_toolbar.panels.headers.HeaderDebugPanel',
    #'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
    'debug_toolbar.panels.request.RequestPanel',
    'debug_toolbar.panels.sql.SQLDebugPanel',
    'debug_toolbar.panels.signals.SignalDebugPanel',
    'debug_toolbar.panels.cache.CachePanel',
    #'debug_toolbar.panels.logger.LoggingPanel',
    'debug_toolbar.panels.logging.LoggingPanel',
    #'debug_toolbar.panels.staticfiles.StaticFilesPanel',
    'debug_toolbar.panels.templates.TemplatesPanel',
    'debug_toolbar.panels.redirects.RedirectsPanel',
    'debug_toolbar_mongo.panel.MongoDebugPanel',
    #'memcache_toolbar.panels.memcache.MemcachePanel',
    #pip install git+https://github.com/ross/memcache-debug-panel.git  (to use memcache_toolbar)

    #  Enabling the profiler has a weird bug as of django-debug-toolbar==0.9.4 and
    #  Django=1.3.1/1.4 where requests to views get duplicated (your method gets
    #  hit twice). So you can uncomment when you need to diagnose performance
    #  problems, but you shouldn't leave it on.
    #  'debug_toolbar.panels.profiling.ProfilingPanel',
)


DEBUG_TOOLBAR_CONFIG = {
    'INTERCEPT_REDIRECTS': False,
    'SHOW_TOOLBAR_CALLBACK': lambda _: True,
}

启动调试环境:sudo -u www-data /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/manage.py lms runserver 0.0.0.0:5000 --settings aws