0

I'm doing some extra queries(using object attributes) on submit/save(to define the file upload_to) and I want to see them in the django_debug_toolbar.

I'm doing the same queries for each file, and I want to do some optimization, to see how many there are, is just one call, or are called for each attribute.

2
  • Why can't you use IDE debugger to track this down? Commented Jan 28, 2018 at 17:00
  • I don't know if it is possible - I have Pycharm; I want to know the real number of calls in the database and the query Commented Jan 28, 2018 at 17:16

1 Answer 1

3

Use the debug_toolbar.panels.sql.SQLPanel. In your settings file:

DEBUG_TOOLBAR_PANELS = [
    'debug_toolbar.panels.versions.VersionsPanel',
    'debug_toolbar.panels.timer.TimerPanel',
    'debug_toolbar.panels.settings.SettingsPanel',
    'debug_toolbar.panels.headers.HeadersPanel',
    'debug_toolbar.panels.request.RequestPanel',
    'debug_toolbar.panels.sql.SQLPanel',  # important one
    'debug_toolbar.panels.staticfiles.StaticFilesPanel',
    'debug_toolbar.panels.templates.TemplatesPanel',
    'debug_toolbar.panels.cache.CachePanel',
    'debug_toolbar.panels.signals.SignalsPanel',
    'debug_toolbar.panels.logging.LoggingPanel',
    'debug_toolbar.panels.redirects.RedirectsPanel',
]

After that, when you POST to your URL and display some HTML as result you should see a section in the debug toolbar to see which queries were executed. You might need to temporally disable any redirections in order to get the profiling for the POST and not for the redirected GET.

Sign up to request clarification or add additional context in comments.

1 Comment

Disabling redirects fixed my issue where I was not seeing any of the update/inserts in the admin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.