6

Django debug toolbar is a great tool to profile slow SQL queries - among other things. I'm able to do this for GET responses in my Django app. My question is: how do I profile (and optimize) my POST responses?

Hassan Baig
  • 15,055
  • 27
  • 102
  • 205
  • 1
    Hassan, can you make your question clearer? I've just tried DDT and it seems to work **equally as well with views using GET and POST**. The only thing that you may have to be careful about is if the POST view ends up with a redirect, but there's an "Intercept redirects" box to tick for that. – raphv Jul 11 '16 at 14:26
  • @raphv: hold on buddy, give me a sec – Hassan Baig Jul 11 '16 at 14:35
  • @raphv: Okay, so I think intercept redirects solved my problem. Most of the POST requests I was looking at were redirecting. And I hadn't ticked that option. You could leave that as an answer, and I'll accept it :-) – Hassan Baig Jul 11 '16 at 14:52
  • OK. I've made it an answer and added a bit about AJAX calls – raphv Jul 11 '16 at 14:57

1 Answers1

9

Django-Debug-Toolbar works the same with GET and POST requests.

However, one common UI design pattern is that successful form submissions lead to a redirect, which loads a new view and makes you lose all the SQL history in DDT.

If this is the case, one of the panels on DDT allows you to intercept redirects and inspect SQL queries at each step.

Also, if your problem comes from making AJAX calls, you should have a look at the answers to this question: How to use django-debug-toolbar on AJAX calls?

Community
  • 1
  • 1
raphv
  • 1,153
  • 7
  • 10