django-debug-toolbar 在获取 sql 统计信息时中断管理
django-debug-toolbar breaking on admin while getting sql stats
环境:django 调试工具栏在用于获取 sql 统计信息时中断,否则它在其他页面上工作正常,仅在具有 sql 查询的页面上中断。
Request Method: GET
Request URL: http://www.blog.local/admin/
Django Version: 1.9.7
Python Version: 2.7.6
Installed Applications:
[
....
'django.contrib.staticfiles',
'debug_toolbar']
Installed Middleware:
[
...
'debug_toolbar.middleware.DebugToolbarMiddleware']
Traceback:
File "/home/vagrant/www/dx/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
235. response = middleware_method(request, response)
File "/home/vagrant/www/dx/venv/local/lib/python2.7/site-packages/debug_toolbar/middleware.py" in process_response
129. panel.generate_stats(request, response)
File "/home/vagrant/www/dx/venv/local/lib/python2.7/site-packages/debug_toolbar/panels/sql/panel.py" in generate_stats
192. query['sql'] = reformat_sql(query['sql'])
File "/home/vagrant/www/dx/venv/local/lib/python2.7/site-packages/debug_toolbar/panels/sql/utils.py" in reformat_sql
27. return swap_fields(''.join(stack.run(sql)))
File "/home/vagrant/www/dx/venv/local/lib/python2.7/site-packages/sqlparse/engine/filter_stack.py" in run
29. stream = filter_.process(stream)
Exception Type: TypeError at /admin/
Exception Value: process() takes exactly 3 arguments (2 given)
sqlparse 最新版本今天发布,与 django-debug-toolbar 1.4 版、Django 1.9 版不兼容
解决方法是强制安装 pip sqlparse==0.1.19
sqlparse
的最新版本与 django-debug-toolbar==1.4
不兼容。
您的选择是:
- 升级
django-debug-toolbar
到 1.5
- 强制安装
sqlparse==0.1.19
@雷克斯索尔兹伯里
这是不正确的。
您必须安装
django-debug-toolbar==1.5
sqlparse==0.2.0
或
django-debug-toolbar==1.4
sqlparse==0.1.19
在 Cloud9 上测试,使用 django 1.9.2
抱歉,但对我来说,Django 1.8.11 只适用于此:
django-debug-toolbar==1.5
sqlparse==0.2.1
环境:django 调试工具栏在用于获取 sql 统计信息时中断,否则它在其他页面上工作正常,仅在具有 sql 查询的页面上中断。
Request Method: GET
Request URL: http://www.blog.local/admin/
Django Version: 1.9.7
Python Version: 2.7.6
Installed Applications:
[
....
'django.contrib.staticfiles',
'debug_toolbar']
Installed Middleware:
[
...
'debug_toolbar.middleware.DebugToolbarMiddleware']
Traceback:
File "/home/vagrant/www/dx/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
235. response = middleware_method(request, response)
File "/home/vagrant/www/dx/venv/local/lib/python2.7/site-packages/debug_toolbar/middleware.py" in process_response
129. panel.generate_stats(request, response)
File "/home/vagrant/www/dx/venv/local/lib/python2.7/site-packages/debug_toolbar/panels/sql/panel.py" in generate_stats
192. query['sql'] = reformat_sql(query['sql'])
File "/home/vagrant/www/dx/venv/local/lib/python2.7/site-packages/debug_toolbar/panels/sql/utils.py" in reformat_sql
27. return swap_fields(''.join(stack.run(sql)))
File "/home/vagrant/www/dx/venv/local/lib/python2.7/site-packages/sqlparse/engine/filter_stack.py" in run
29. stream = filter_.process(stream)
Exception Type: TypeError at /admin/
Exception Value: process() takes exactly 3 arguments (2 given)
sqlparse 最新版本今天发布,与 django-debug-toolbar 1.4 版、Django 1.9 版不兼容
解决方法是强制安装 pip sqlparse==0.1.19
sqlparse
的最新版本与 django-debug-toolbar==1.4
不兼容。
您的选择是:
- 升级
django-debug-toolbar
到1.5
- 强制安装
sqlparse==0.1.19
@雷克斯索尔兹伯里 这是不正确的。
您必须安装
django-debug-toolbar==1.5
sqlparse==0.2.0
或
django-debug-toolbar==1.4
sqlparse==0.1.19
在 Cloud9 上测试,使用 django 1.9.2
抱歉,但对我来说,Django 1.8.11 只适用于此:
django-debug-toolbar==1.5
sqlparse==0.2.1