2
0
Fork 0

Get settings from env

This commit is contained in:
Luca 2022-04-13 19:02:19 +02:00
parent be767b6ee2
commit 08dd614f67
1 changed files with 11 additions and 6 deletions

View File

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
""" """
from pathlib import Path from pathlib import Path
from os import getenv
# 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 +21,12 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/4.0/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-pdgzgd_!w&&cfqc%r&!v_^6pgf!sza=2wim67()!(kaf7_6-5)' SECRET_KEY = getenv('SECRET_KEY', 'django-insecure-pdgzgd_!w&&cfqc%r&!v_^6pgf!sza=2wim67()!(kaf7_6-5)')
# 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 = getenv('ENVIRONMENT', 'development') == 'production'
ALLOWED_HOSTS = [] ALLOWED_HOSTS = getenv('ALLOWED_HOSTS', '').split(',')
# Application definition # Application definition
@ -77,8 +78,12 @@ WSGI_APPLICATION = 'shiftregister.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.'+getenv('DB_ENGINE', 'sqlite3'),
'NAME': BASE_DIR / 'db.sqlite3', 'NAME': getenv('DB_NAME', BASE_DIR / 'db.sqlite3'),
'USER': getenv('DB_USER', ''),
'PASSWORD': getenv('DB_PASSWORD', ''),
'HOST': getenv('DB_HOST', ''),
'PORT': getenv('DB_PORT', ''),
} }
} }
@ -105,7 +110,7 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/ # https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'de-de'
TIME_ZONE = 'Europe/Berlin' TIME_ZONE = 'Europe/Berlin'