Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show toolbar for docker's internal IP address #1887

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

tim-schilling
Copy link
Contributor

Description

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

Fixes #1854

Checklist:

  • I have added the relevant tests for this change.
  • I have added an item to the Pending section of docs/changes.rst.

@tim-schilling
Copy link
Contributor Author

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

@epicserve
Copy link

@tim-schilling,

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

@tim-schilling
Copy link
Contributor Author

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
Copy link

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
Copy link
Contributor Author

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

@epicserve
Copy link

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

@nitairoy
Copy link

nitairoy commented Feb 21, 2024 via email

@matthiask
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Debug Toolbar has stopped showing under Docker
4 participants