django-debug-toolbar icon indicating copy to clipboard operation
django-debug-toolbar copied to clipboard

Django Debug Toolbar is not presented after PUT request DRF

Open OleksandrPozden opened this issue 2 years ago • 8 comments

DjDT disappears after making either PUT or PATCH requests in the browsable DRF API. For GET and POST requests everything works fine. After a single PUT request debug toolbar disappears. And after a single GET request, it shows back.

If open dev tools, djdt keeps being presented inside of HTML.

The server is running on the localhost with DEBUG=True. I followed the official installation tutorial:

  • "127.0.0.1" are listed in INTERNAL_IPS
  • 'debug_toolbar.middleware.DebugToolbarMiddleware' listed as high as possible. Higher only 'corsheaders.middleware.CorsMiddleware' and 'django.middleware.security.SecurityMiddleware'

Has anyone met with this?

OleksandrPozden avatar Feb 26 '23 21:02 OleksandrPozden

That's interesting. I had the suspicion that maybe the toolbar JS fails since it hooks into XHR/fetch but it doesn't look as if a failure should hide the toolbar.

matthiask avatar Mar 06 '23 10:03 matthiask

running djdt.init() in the browser console made the toolbar show up

maziar-dandc avatar Jul 09 '23 22:07 maziar-dandc

POST method doesn't work either

ArtemIsmagilov avatar Jan 28 '24 21:01 ArtemIsmagilov

Hi folks. Would either of you be able to create a reproducible example for us to investigate?

tim-schilling avatar Jan 28 '24 21:01 tim-schilling

Hi folks. Would either of you be able to create a reproducible example for us to investigate?

https://www.loom.com/share/b18a95dc61d647329a9232b0eddd07e9?sid=b3560fd2-7dd4-4dc6-a2ed-d1492ccf7ec4 Please refer to this video to see the bug logged. The toolbar disappears when i make a put or post request. Gets back on GET request?

HarshGuptaShorthillsAI avatar Feb 19 '24 06:02 HarshGuptaShorthillsAI

Thank you @HarshGuptaShorthillsAI. I didn't doubt that it was happening. What I'm looking for is a minimal django project that reproduces this so I can look into why exactly this is happening on my local machine. There could be a slight difference in how you have the project setup versus what I would do. That could lead to the difference in results.

The toolbar has an example project if you want to fork that and start from there.

tim-schilling avatar Feb 19 '24 11:02 tim-schilling

Surprisingly did not have to do anything special to reproduce it, just latest django, drf (+basic api), djdt. Tried both chrome (heavy extension use) and firefox (vanilla).

https://github.com/MaziyarMK/djdt_bug

Lemme know if that does reproduce on your side as well.

maziar-dandc avatar Feb 20 '24 08:02 maziar-dandc

DRF 3.15 now includes a fix to address this issue.

realsuayip avatar Mar 22 '24 21:03 realsuayip