django-commons / django-debug-toolbar

A configurable set of panels that display various debug information about the current request/response.
https://django-debug-toolbar.readthedocs.io
BSD 3-Clause "New" or "Revised" License
8.08k stars 1.05k forks source link

Show toolbar for docker's internal IP address #1887

Closed tim-schilling closed 8 months ago

tim-schilling commented 8 months ago

Description

This attempts to automatically look up the docker internal IP address for the developer.

Fixes #1854

Checklist:

tim-schilling commented 8 months ago

@epicserve could you give this a test run for me?

epicserve commented 8 months ago

@tim-schilling,

I tested it out and it worked. You can see my code here.

tim-schilling commented 8 months ago

Excellent thank you. @matthiask I know this is a hack, but I personally don't see a difference between asking a developer to copy/paste the hack themselves versus us writing it in for them and letting them know where it exists. At least for a development tool like this.

I do wonder if we could setup a test that's better than a mock though. @epicserve do you have any ideas on how that could be done? I haven't researched it at all, so I apologize if it's just a search away.

nitairoy commented 8 months ago

If you're developing with a Django server in a Docker container with docker, the instructions for enabling the toolbar don't work. The reason is related to the fact that the actual address that you would need to add to INTERNAL_IPS is going to be something dynamic, like 172.24.0.1. Rather than trying to dynamically set the value of INTERNAL_IPS, the straightforward solution is to replace the function that enables the toolbar, in your settings.py, for example:

DEBUG_TOOLBAR_CONFIG = { 'SHOW_TOOLBAR_CALLBACK': lambda _request: DEBUG }

This should also work for other dynamic routing situations, like Vagrant or Heroku.

follow the link: https://stackoverflow.com/questions/10517765/django-debug-toolbar-not-showing-up

tim-schilling commented 8 months ago

@nitairoy did you attempt to use the code in this PR? Also, please see the discussion in #1854.

epicserve commented 8 months ago

@tim-schilling, mocking is how I would handle testing it. I can't think of a better alternative.

nitairoy commented 8 months ago

Yes, I did and it work.

Best Regards, Nitai Roy

On 20 Feb, 2024, at 5:13 PM, Tim Schilling @.***> wrote:

@nitairoy https://github.com/nitairoy did you attempt to use the code in this PR? Also, please see the discussion in #1854 https://github.com/jazzband/django-debug-toolbar/issues/1854.

— Reply to this email directly, view it on GitHub https://github.com/jazzband/django-debug-toolbar/pull/1887#issuecomment-1953988008, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXZKDP2TCXOL5JZGI7XJETYUSAOZAVCNFSM6AAAAABDNPQ6RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTHE4DQMBQHA. You are receiving this because you were mentioned.

matthiask commented 8 months ago

Excellent thank you. @matthiask I know this is a hack, but I personally don't see a difference between asking a developer to copy/paste the hack themselves versus us writing it in for them and letting them know where it exists. At least for a development tool like this.

Yes, I agree. It would certainly be nice if the toolbar worked out of the box for everyone.

johnthagen commented 2 months ago

For historical purposes, this caused a regression

Fix in