change settings.py variable for .env config file
This commit is contained in:
1 parent
bb75e58489
commit
2ebc57fa98
1 file changed
+14
-9
+14
-9
@@ -10,7 +10,12 @@ For the full list of settings and their values, see
|
|||||||
https://docs.djangoproject.com/en/3.2/ref/settings/
|
https://docs.djangoproject.com/en/3.2/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
# Lädt die Variablen aus der .env Datei
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
@@ -20,12 +25,12 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||||||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = 'django-insecure-#xh(_vl!ccdoop$+6@ze-g%%o9dn%ks(b!2c0=w)rxq25p5(p%'
|
SECRET_KEY = os.getenv('SECRET_KEY')
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = os.getenv('DEBUG') == 'True'
|
||||||
|
|
||||||
ALLOWED_HOSTS = ["gd.pi.lan"]
|
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost').split(',')
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
@@ -86,12 +91,12 @@ WSGI_APPLICATION = 'project.wsgi.application'
|
|||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.mysql",
|
'ENGINE': "django.db.backends.mysql",
|
||||||
"NAME": "hansolo_django_gd",
|
'NAME': os.getenv('DB_NAME'),
|
||||||
"USER": "hansolo_django_gd",
|
'USER': os.getenv('DB_USER'),
|
||||||
"PASSWORD": "Django123",
|
'PASSWORD': os.getenv('DB_PASSWORD'),
|
||||||
"HOST": "localhost",
|
'HOST': os.getenv('DB_HOST'),
|
||||||
"PORT": "3306",
|
'PORT': os.getenv('DB_PORT'),
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"init_command": "SET sql_mode='STRICT_TRANS_TABLES'",
|
"init_command": "SET sql_mode='STRICT_TRANS_TABLES'",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user