From 093e0f25017ba4561d6f962813d93a880b40fa61 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Mon, 31 Oct 2022 00:48:02 +0100 Subject: [PATCH] Add local IP to debug conf --- src/charasheet/settings.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/charasheet/settings.py b/src/charasheet/settings.py index 0e9caf7..f751cc6 100644 --- a/src/charasheet/settings.py +++ b/src/charasheet/settings.py @@ -3,10 +3,6 @@ from pathlib import Path import environ -INTERNAL_IPS = [ - "127.0.0.1", -] - PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent BASE_DIR = PROJECT_ROOT / "src" CONTRIB_DIR = PROJECT_ROOT / "contrib" @@ -35,8 +31,20 @@ SECRET_KEY = env("SECRET_KEY") DEBUG = env("DEBUG") DEBUG_TOOLBAR = env("DEBUG") and env("DEBUG_TOOLBAR") +INTERNAL_IPS = [ + "127.0.0.1", +] ALLOWED_HOSTS = env("ALLOWED_HOSTS") +if DEBUG: + import socket + + hostname = socket.gethostname() + ip = socket.gethostbyname(hostname) + INTERNAL_IPS.append(ip) + ALLOWED_HOSTS.append(ip) + + # Application definition DJANGO_APPS = [