text: """
  Django settings for web project.
  
  Generated by 'django-admin startproject' using Django 3.1.7.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/3.1/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/3.1/ref/settings/
  """
  
  import os
  from pathlib import Path
  
  # Build paths inside the project like this: BASE_DIR / 'subdir'.
  BASE_DIR = Path(__file__).resolve().parent.parent
  
  
  # Quick-start development settings - unsuitable for production
  # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = os.environ["SECRET_KEY"]
  
  # Building a variable to pivot between prod and dev environments
  stage = os.environ["stage"]
  
  if stage == "prod":
      DEBUG = False
  if stage == "dev":
      DEBUG = True
  
  # Using pipe delimeted string to allow the environment vars to separate a list of hosts. 
  ALLOWED_HOSTS = os.environ["ALLOWED_HOSTS"].split('|')
  
  
  # Application definition
  
  INSTALLED_APPS = [
      "django.contrib.admin",
      "django.contrib.auth",
      "django.contrib.contenttypes",
      "django.contrib.sessions",
      "django.contrib.messages",
      "django.contrib.staticfiles",
      "app",
  ]
  
  MIDDLEWARE = [
      "django.middleware.security.SecurityMiddleware",
      "django.contrib.sessions.middleware.SessionMiddleware",
      "django.middleware.common.CommonMiddleware",
      "django.middleware.csrf.CsrfViewMiddleware",
      "django.contrib.auth.middleware.AuthenticationMiddleware",
      "django.contrib.messages.middleware.MessageMiddleware",
      "django.middleware.clickjacking.XFrameOptionsMiddleware",
  ]
  
  ROOT_URLCONF = "web.urls"
  
  TEMPLATES = [
      {
          "BACKEND": "django.template.backends.django.DjangoTemplates",
          "DIRS": [os.path.join(BASE_DIR, "templates")],
          "APP_DIRS": True,
          "OPTIONS": {
              "context_processors": [
                  "django.template.context_processors.debug",
                  "django.template.context_processors.request",
                  "django.contrib.auth.context_processors.auth",
                  "django.contrib.messages.context_processors.messages",
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = "web.wsgi.application"
  
  
  # Database
  # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
  
  if os.environ["stage"] == "prod":
      # Postgres for local 'prod' deploy
      DATABASES = {
          'default': {
              'ENGINE': "django.db.backends.postgresql",
              'NAME': os.environ["sqlname"],
              'USER': os.environ["sqluser"],
              'PASSWORD': os.environ["sqlpwd"],
              'HOST': os.environ["sqlserv"],
              'PORT': '5432',
              'OPTIONS': {
                  'sslmode': 'require',
              },
          },
      }
  else:
      # Local database for local 'dev' deploy
      DATABASES = {
          "default": {
              "ENGINE": "django.db.backends.sqlite3",
              "NAME": BASE_DIR / "db.sqlite3",
          }
      }
  
  
  # Password validation
  # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
  
  AUTH_PASSWORD_VALIDATORS = [
      {"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",},
      {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
      {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
      {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
  ]
  
  
  # Internationalization
  # https://docs.djangoproject.com/en/3.1/topics/i18n/
  
  LANGUAGE_CODE = "en-us"
  TIME_ZONE = "UTC"
  USE_I18N = True
  USE_L10N = True
  USE_TZ = True
  
  # Static and Media Files
  
  # STATIC_URL = "/static/"
  
  if stage == "prod":
      AZURE_STORAGE_KEY = os.environ.get('AZURE_STORAGE_KEY', False)+"==" # wierd env string issue
      AZURE_ACCOUNT_NAME = os.environ.get('AZURE_ACCOUNT_NAME', False)
      AZURE_STATIC_CONTAINER = os.environ.get('AZURE_STATIC_CONTAINER', 'static')
      AZURE_CUSTOM_DOMAIN = f'{AZURE_ACCOUNT_NAME}.blob.core.windows.net'  # CDN URL
      STATIC_URL = f'https://{AZURE_CUSTOM_DOMAIN}/{AZURE_STATIC_CONTAINER}/'
      STATIC_ROOT = os.path.join("app", "static")
      log_path = "prod_blog_log.log"
      DEFAULT_FILE_STORAGE = 'web.backend.AzureMediaStorage'
      STATICFILES_STORAGE  = 'web.backend.AzureStaticStorage'
  
  if stage == "dev":
      STATIC_URL = "/static/"
      STATIC_ROOT = os.path.join(os.environ["abspath"], "app", "static", "app")
      log_path = os.path.join(os.environ["abspath"], "data", "non_prod_blog_log.log")
  
  
  LOGGING = {
      "version": 1,
      "disable_existing_loggers": False,
      "filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}},
      "handlers": {
          "logfile": {
              "class": "logging.handlers.WatchedFileHandler",
              "filename": log_path,
          }
      },
      "loggers": {
          "django": {"handlers": ["logfile"], "level": "ERROR", "propagate": False,}
      },
  }
  