Add environment config

This commit is contained in:
Edgar P. Burkhart 2022-05-21 18:45:53 +02:00
parent ad537e737b
commit 1300132d69
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -11,23 +11,24 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
""" """
from pathlib import Path from pathlib import Path
import os
# 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
MEDIA_ROOT = Path("/var/lib/nummi") MEDIA_ROOT = Path(os.environ.get("NUMMI_MEDIA_ROOT", "/var/lib/nummi"))
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# 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 = "h/0OOuNSBRJy9Suo172Y5sJYGgmDqanh" SECRET_KEY = os.environ.get("NUMMI_SECRET", "dev_sDo6gl1Yf8GIE7XEA2B4xF841eMOpfG1")
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False DEBUG = os.environ.get("NUMMI_DEBUG", None) == "True"
ALLOWED_HOSTS = ["nummi.edgarpierre.fr"] ALLOWED_HOSTS = [os.environ.get("NUMMI_HOST", "localhost")]
CSRF_TRUSTED_ORIGINS = ["https://nummi.edgarpierre.fr"] CSRF_TRUSTED_ORIGINS = [f"https://{os.environ.get('NUMMI_HOST', 'localhost')}"]
# Application definition # Application definition