Created
July 2, 2019 01:46
-
-
Save gh640/963f275cb8b994d5f35ef7324f62bb64 to your computer and use it in GitHub Desktop.
Allow Django Debug Toolbar to be displayed when the app is running in a Docker container
This file contains 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
"""Allow Django Debug Toolbar to be displayed when the app runs in a Docker container | |
See: https://gist.github.com/douglasmiranda/9de51aaba14543851ca3 | |
""" | |
import socket | |
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2'] | |
# Add address for Docker host to `INTERNAL_IPS` to allow debug-toolbar to be | |
# displayed in app running in Docker container. | |
def _change_last_number_to_1(ip): | |
return '{}.1'.format(ip[: ip.rfind('.')]) | |
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) | |
INTERNAL_IPS += [_change_last_number_to_1(ip) for ip in ips] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment