old_contents: """
  Django settings for d4s2 project.
  
  Generated by 'django-admin startproject' using Django 1.9.4.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/1.9/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/1.9/ref/settings/
  """
  
  from d4s2.settings_base import *
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = os.getenv('D4S2_SECRET_KEY')
  
  # Database
  # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'NAME': os.getenv('POSTGRES_DB'),
          'USER': os.getenv('POSTGRES_USER'),
          'PASSWORD': os.getenv('POSTGRES_PASSWORD'),
          'HOST': os.getenv('POSTGRES_HOST', 'db'),
          'PORT': os.getenv('POSTGRES_PORT', 5432),
      }
  }
  
  # To enable SMTP email, set D4S2_SMTP_HOST
  if os.getenv('D4S2_SMTP_HOST') is not None:
    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    EMAIL_HOST = os.getenv('D4S2_SMTP_HOST')
  
  # Additional production security settings
  if os.getenv('D4S2_PRODUCTION'):
    ALLOWED_HOSTS = [os.getenv('D4S2_ALLOWED_HOST')]
    SECURE_HSTS_SECONDS = 3600
    SECURE_HSTS_INCLUDE_SUBDOMAINS = True
    SECURE_CONTENT_TYPE_NOSNIFF = True
    SESSION_COOKIE_SECURE = True
    SECURE_BROWSER_XSS_FILTER = True
    SECURE_SSL_REDIRECT = True
    SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
    CSRF_COOKIE_SECURE = True
    X_FRAME_OPTIONS = 'DENY'
    DEBUG = False
  
new_contents: """
  Django settings for d4s2 project.
  
  Generated by 'django-admin startproject' using Django 1.9.4.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/1.9/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/1.9/ref/settings/
  """
  
  from d4s2.settings_base import *
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = os.getenv('D4S2_SECRET_KEY')
  
  # Database
  # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'NAME': os.getenv('POSTGRES_DB'),
          'USER': os.getenv('POSTGRES_USER'),
          'PASSWORD': os.getenv('POSTGRES_PASSWORD'),
          'HOST': os.getenv('POSTGRES_HOST', 'db'),
          'PORT': os.getenv('POSTGRES_PORT', 5432),
      }
  }
  
  # To enable SMTP email, set D4S2_SMTP_HOST
  if os.getenv('D4S2_SMTP_HOST') is not None:
    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    EMAIL_HOST = os.getenv('D4S2_SMTP_HOST')
    EMAIL_FROM_ADDRESS = os.getenv('D4S2_EMAIL_FROM_ADDRESS')
  
  # Additional production security settings
  if os.getenv('D4S2_PRODUCTION'):
    ALLOWED_HOSTS = [os.getenv('D4S2_ALLOWED_HOST')]
    SECURE_HSTS_SECONDS = 3600
    SECURE_HSTS_INCLUDE_SUBDOMAINS = True
    SECURE_CONTENT_TYPE_NOSNIFF = True
    SESSION_COOKIE_SECURE = True
    SECURE_BROWSER_XSS_FILTER = True
    SECURE_SSL_REDIRECT = True
    SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
    CSRF_COOKIE_SECURE = True
    X_FRAME_OPTIONS = 'DENY'
    DEBUG = False
  
subject: Update settings_docker to pick up D4S2_EMAIL_FROM_ADDRESS variable