Improve integration with Django Debug Toolbar #9213
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, DRF does not work well with
debug_toolbar
, due to the way it handles non-GET and non-POST requests.To perform
PUT
,PATCH
,DELETE
andOPTIONS
requests in browsable API, we send an ajax request to fetch the resulting HTML. The contents are then dynamically rendered using JavaScript.During this time, the entire toolbar gets re-rendered (with proper data) but since the related JavaScript code is not executed (normally done on document load), the toolbar is instead hidden.
I added a simple check during JavaScript re-render to load the toolbar. It's unlikely this issue could be solved on
debug_toolbar
side given the way DRF handles content rendering.IMHO this should be a great QOL improvement given how annoying it becomes to track requests with mentioned methods.
Related:
django-commons/django-debug-toolbar#1743