Load settings from .env

pull/7/head
Jannis Portmann 2023-04-05 18:19:21 +02:00
parent 35ec98f830
commit a53a6f9344
1 changed files with 16 additions and 8 deletions

View File

@ -12,6 +12,12 @@ https://docs.djangoproject.com/en/4.1/ref/settings/
import os
from pathlib import Path
from dotenv import load_dotenv
# Parse .env
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@ -145,11 +151,13 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
CRISPY_TEMPLATE_PACK = 'bootstrap5'
if DEBUG:
# Mailhog configuration
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = '0.0.0.0'
EMAIL_PORT = 1025
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
# Email Settings
# SMTP Server
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.getenv('SMTP_HOST')
EMAIL_PORT = os.getenv('SMTP_PORT')
EMAIL_HOST_USER = os.getenv('SMTP_USER')
EMAIL_HOST_PASSWORD = os.getenv('SMTP_PASSWORD')
EMAIL_USE_SSL = True