drupal2spip_lal/drupal2spip_lal/settings/production.py

58 lines
2.0 KiB
Python

"""
Production settings.
- validate the configuration
- disable debug mode
- load secret key from environment variables
- set other production configurations
"""
from django.core.exceptions import ImproperlyConfigured
from .base import * # noqa
from .base import TEMPLATES, env
# CONFIGURATION VALIDATION
# ------------------------------------------------------------------------------
# Ensure that the database configuration has been set
if not env('DJANGO_DATABASE_URL', default=None):
raise ImproperlyConfigured(
"No database configuration has been set, you should check "
"the value of your DATABASE_URL environment variable."
)
# Ensure that the default email address has been set
if not env('DEFAULT_FROM_EMAIL', default=None):
raise ImproperlyConfigured(
"No default email address has been set, you should check "
"the value of your DEFAULT_FROM_EMAIL environment variable."
)
# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#debug
DEBUG = False
# https://docs.djangoproject.com/en/stable/ref/settings/#secret-key
SECRET_KEY = env('DJANGO_SECRET_KEY')
# https://docs.djangoproject.com/en/stable/ref/settings/#allowed-hosts
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=[])
# TEMPLATES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#templates
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
TEMPLATES[0]['OPTIONS']['loaders'] = [
(
'django.template.loaders.cached.Loader',
[
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
],
)
]
# ------------------------------------------------------------------------------
# APPLICATION AND 3RD PARTY LIBRARY SETTINGS
# ------------------------------------------------------------------------------