Error django-debug-toolbar breaking on admin while getting sql stats

0 votes

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)

How to solve this?

Jun 12, 2020 in Python by kartik
• 37,510 points
1,012 views

1 answer to this question.

0 votes

Hello @kartik,

You just need to be able to import the value of DJANGO_SETTINGS_MODULE when you're in a location that isn't in your project root. One easy way of doing that is to (1) add the parent of your project folder to PYTHONPATH, (2) change DJANGO_SETTINGS_MODULE to projectfoldername.settings.

Hope this works!!

answered Jun 12, 2020 by Niroj
• 82,880 points

Related Questions In Python

0 votes
1 answer

i am getting an error on pycharm while installing packages

Hi, @There, $ pip install gevent --pre $ pip ...READ MORE

answered Oct 27, 2020 in Python by Gitika
• 65,910 points
2,127 views
0 votes
1 answer

Django: Display a custom error message for admin validation error

Hello @kartik, Without looking, it sounds like the ...READ MORE

answered Jun 12, 2020 in Python by Niroj
• 82,880 points
7,174 views
+1 vote
2 answers

Error:Django gives Bad Request (400) when DEBUG = False

Tried this and it resolved all my ...READ MORE

answered Sep 25, 2020 in Python by Agaba
5,662 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,069 views
0 votes
1 answer
0 votes
1 answer

How do I add a link from the Django admin page of one object to the admin page of a related object?

Hello @kartik, Set show_change_link to True (False by default) in your inline ...READ MORE

answered Jun 12, 2020 in Python by Niroj
• 82,880 points
9,951 views
+1 vote
1 answer

Error:Getting Site Matching Query Does Not Exist Error after creating django admin

Hello @kartik, The Site object for your Django project is ...READ MORE

answered Jun 22, 2020 in Python by Niroj
• 82,880 points
11,917 views
0 votes
1 answer

Errors in fields not displaying on Django admin form?

Hiii, Here is how you can see what ...READ MORE

answered Apr 29, 2020 in Python by Niroj
• 82,880 points
4,255 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP