I'm curious if there's a reasonable way to use the (amazing) django-debug-toolbar with AJAX queries.
For example, I use a jQuery $.get with a bunch of parameters to hit a Django URL and load it inline. If I have an error with that, it isn't registered on the toolbar. I also can't use it by copying the AJAX URL because DDT attaches to the body tag of the response, and it wouldn't make any sense to be including body tags with AJAX responses.
Any direction would be helpful! Thanks!
Ddt plugs itself into a response, which means that there is no standard way of browsing its panels for AJAX request. Also, AJAX response can be in JSON format, which makes it impossible for ddt to plug into it.
Personally I'd find a way of logging ddt output to a text file, or maybe it supports client-server architecture in which client works inside AJAX request handler and sends data to the server? I don't know what's possible as there are dozen ddt clones out there.
I had the same problem before! And as I'm doing more and more AJAX heavy applications, I released a Django Application and a Chrome extension that together solved exactly that problem.
All the information is in the github repository.
I've hit this problem recently. My quick-n-dirty-but-working solution was just to add some HTML views to flex the same code.
So for example, if I can see in NewRelic that 90% of my website's time is spent in an ajax call to /search_for_book?title=, my code might look like this:
The bottleneck will be somewhere in the _search_for_book code; whether we call it by ajax is irrelevant to diagnosing its inefficiencies (in my case, at least; YMMV)
I wrote the Request History Panel for Django Debug Toolbar that can be added to the Django Debug Toolbar to view requests other than the current one (including AJAX requests).
Install via pip:
In settings.py add
'ddt_request_history.panels.request_history.RequestHistoryPanel'
toDEBUG_TOOLBAR_PANELS
e.g.: