Load settings from .env

This commit is contained in:
Jannis Portmann 2023-04-05 18:19:21 +02:00
parent 35ec98f830
commit a53a6f9344

View file

@ -12,6 +12,12 @@ https://docs.djangoproject.com/en/4.1/ref/settings/
import os import os
from pathlib import Path from pathlib import Path
from dotenv import load_dotenv
# Parse .env
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
@ -145,11 +151,13 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
CRISPY_TEMPLATE_PACK = 'bootstrap5' CRISPY_TEMPLATE_PACK = 'bootstrap5'
if DEBUG:
# Mailhog configuration # Email Settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # SMTP Server
EMAIL_HOST = '0.0.0.0' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_PORT = 1025
EMAIL_HOST_USER = '' EMAIL_HOST = os.getenv('SMTP_HOST')
EMAIL_HOST_PASSWORD = '' EMAIL_PORT = os.getenv('SMTP_PORT')
EMAIL_USE_TLS = False EMAIL_HOST_USER = os.getenv('SMTP_USER')
EMAIL_HOST_PASSWORD = os.getenv('SMTP_PASSWORD')
EMAIL_USE_SSL = True