Django-debug-toolbar: No sql stacktrace

Created on 14 Oct 2014  ·  12Comments  ·  Source: jazzband/django-debug-toolbar

I've installed django debug toolbar and all the panels apart from the sql panel seem to work.

On opening the sql panel I get the messages:

SQL queries from 0 connections
No SQL queries were recorded during this request.

My settings.py:

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
#'silk.middleware.SilkyMiddleware',
'pagination.middleware.PaginationMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

Add the debug toolbar

if DEBUG:
DEBUG_TOOLBAR_PATCH_SETTINGS = True
ENABLE_STACKTRACES = True
INSTALLED_APPS += (
'debug_toolbar',
)
INTERNAL_IPS = ('10.0.2.2', '127.0.0.1', '0.0.0.0',)

Any ideas or any steps I can take to further debug this? Thanks. The only thing that is affected is the SQL stacktrace...

Support request

Most helpful comment

Just found that if you have 'debug_toolbar.middleware.DebugToolbarMiddleware', twice in MIDDLEWARE_CLASSES for whatever reason, the same thing happens (always No SQL queries were recorded during this request.)

All 12 comments

Try moving the debug toolbar further up the list of the middlewares.

Have tried moving it to the very top. No change.
Im startignt o think its to do with the dc connection. Its a postgresql database using psycopg2 as a db engine.

Everything else seems to work perfectly fine.

Any way to debug this further?

Do you have any applications or libraries that alter the database connection?

As a side note, it looks like you are half setup for the Explicit Setup. You should set DEBUG_TOOLBAR_PATCH_SETTINGS = False if you are going to use the Explicit Setup. The other note is that ENABLE_STACKTRACES is a key within the dictionary for the setting DEBUG_TOOLBAR_CONFIG

And to debug this further, I would say to disable any non-standard django middleware then try the page again.

Setting the debug_toolbar_patch_settings to false seems to have worked.

Thanks. Playing around with a few more of the settings....

Closing as it's working now.

Just found that if you have 'debug_toolbar.middleware.DebugToolbarMiddleware', twice in MIDDLEWARE_CLASSES for whatever reason, the same thing happens (always No SQL queries were recorded during this request.)

Having the middleware twice exactly the problem for me.

None of what was mentioned here worked for me. I'm still getting the 0 SQL queries in the panel.

I have this in my INSTALLED_APPS

INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'debug_toolbar', 'debug_panel', 'rest_framework', 'yahshua_intelex', 'corsheaders', 'apis.apps.ApisConfig', 'rest_framework.authtoken', 'my_app' ]

And this in my middleware

MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'debug_panel.middleware.DebugPanelMiddleware', 'my_app.middleware.middleware.RequestProcessor', ]

@Mikebarson The debug_toolbar middleware is missing from your MIDDLEWARE_CLASSES, resp. you only have debug_panel there which is a different thing, and I'm not sure whether it works the same way.

you should select 'history' of panel, then select your endpoint (e.g. /persons/) with clicking on 'switch' button
and finally select 'SQL' of panel and see generated sql.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arnaudblois picture arnaudblois  ·  7Comments

NomadDemon picture NomadDemon  ·  9Comments

stfenjobs picture stfenjobs  ·  6Comments

lfigueira picture lfigueira  ·  10Comments

gosrinin picture gosrinin  ·  8Comments