Skip to content

Commit 56fc02c

Browse files
committed
Use custom function to control debug toolbar
1 parent ee3e7d6 commit 56fc02c

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

api/config/settings.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# Environment specific settings from environment variables or local .env file
1818
SECRET_KEY = os.environ['SECRET_KEY']
1919
DEBUG = bool(os.environ.get('DEBUG', False))
20+
DOCKER = bool(os.environ.get('DOCKER_HOST', False))
2021

2122
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
2223
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -26,19 +27,12 @@
2627

2728
ALLOWED_HOSTS = ['*']
2829

29-
DEBUG_TOOLBAR_PATCH_SETTINGS = False
30-
INTERNAL_IPS = [
31-
'127.0.0.1',
32-
'0.0.0.0',
33-
'::1',
34-
]
30+
def show_debug_toolbar(request):
31+
return DOCKER and DEBUG
3532

36-
if "DOCKER_HOST" in os.environ:
37-
ip = subprocess.check_output(
38-
['ip', 'addr', 'show', 'eth0'],
39-
universal_newlines=True
40-
).split("inet ")[1].split("/")[0]
41-
INTERNAL_IPS.append(ip)
33+
DEBUG_TOOLBAR_CONFIG = {
34+
'SHOW_TOOLBAR_CALLBACK': show_debug_toolbar
35+
}
4236

4337
# Application definition
4438
INSTALLED_APPS = [

0 commit comments

Comments
 (0)