Repository navigation
Improve integration with Django Debug Toolbar - #9213
Merged
Merged
Conversation
Merged
auvipy
self-requested a review
March 6, 2024 10:48
auvipy
requested changes
Mar 6, 2024
auvipy
left a comment
Collaborator
There was a problem hiding this comment.
would you mind sharing some screen shots please? also pulling from main branch?
realsuayip
force-pushed
the
debug_toolbar_integration
branch
from
March 6, 2024 21:27
45ab755 to
036f667
Compare
Contributor
Author
|
@auvipy, Applied changes from main. While preparing for screen capture, I realized that this was not working on Chrome. I had to change it like this: @@ -7,7 +7,7 @@ function replaceDocument(docString) {
if (window.djdt) {
// If Django Debug Toolbar is available, reinitialize it so that
// it can show updated panels from new `docString`.
- document.addEventListener("DOMContentLoaded", djdt.init);
+ window.addEventListener("load", djdt.init);
}
}For some reason, Chrome does not fire The following screen capture uses Chrome: output.mp4 |
auvipy
approved these changes
Mar 7, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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,DELETEandOPTIONSrequests 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_toolbarside 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