27

Environment:django debug toolbar breaking while using to get sql stats else it's working fine on the other pages, breaking only on the pages which have sql queries.

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)
Patlola Praveen
  • 770
  • 9
  • 19
  • We are using an automated VM provisioning system using Vagrant and out of the blue this started appearing about an hour ago. Even old version from git don't work with fresh VMs anymore. I'm stumped. Nothing on the internet about this error and just now this appears. – Ivailo Karamanolev Jul 20 '16 at 10:57
  • @IvailoKaramanolev force pip to install `sqlparse==0.1.19` – Patlola Praveen Jul 20 '16 at 11:13

4 Answers4

48

sqlparse latest version was released today and it's not compatible with django-debug-toolbar version 1.4, Django version 1.9

workaround is force pip to install sqlparse==0.1.19

Patlola Praveen
  • 770
  • 9
  • 19
  • 2
    Can you please identify the version you are working with? I just setup `django-debug-toolbar==1.5` (uploaded to pypi 2016-07-21) a few days ago and it clearly lists `sqlparse>=0.2.0` as a dependency, and works fine for myself and another member of my team. If someone follows this recommendation with django-debug-toolbar==1.5 they will generate the same error. Visitors can easily miss you posted this a day prior to the 1.5 release. – Jmills Jul 26 '16 at 15:09
  • @TheCardCheat This is for django-debug-toolbar version 1.4, i guess they have released it while it was breaking, i have posted this just after sqlparse release. – Patlola Praveen Jul 26 '16 at 19:03
9

the latest version of sqlparse is not compatible with django-debug-toolbar==1.4.

Your choices are:

  • upgrade django-debug-toolbar to 1.5
  • force install sqlparse==0.1.19
Rex Salisbury
  • 478
  • 4
  • 13
  • upgrading django-debug-toolbar to 1.5 automatically upgraded my django-1.7.1 so @miraculixx comment not correct for me – PeterVermont Dec 13 '16 at 15:15
  • you can `pip install django-debug-toolbar==1.5 Django==1.7.1` if you want to stick with that particular django version. Or use `pip install django-debug-toolbar==1.5 "Django<1.8"` to stay below 1.8. – miraculixx Dec 13 '16 at 19:56
3

@Rex Salisbury That's not correct.

You have to install

django-debug-toolbar==1.5
sqlparse==0.2.0

or

django-debug-toolbar==1.4
sqlparse==0.1.19

Tested on Cloud9, with django 1.9.2

taoxuau
  • 61
  • 1
  • 2
0

Sorry,but for me, with Django 1.8.11, it only worked with this:

django-debug-toolbar==1.5
sqlparse==0.2.1
Matheus CAS
  • 161
  • 3
  • 4