text: """
  Django settings for project project.
  
  Generated by 'django-admin startproject' using Django 3.0.6.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/3.0/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/3.0/ref/settings/
  """
  
  import os
  import dj_database_url
  from os import path
  
  if path.exists("env.py"):
      import env
      DEBUG = True
  else:
      DEBUG = False
  
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  
  
  # Quick-start development settings - unsuitable for production
  # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = os.environ.get("SECRET_KEY")
  
  # SECURITY WARNING: don't run with debug turned on in production!
  
  ALLOWED_HOSTS = [
      '127.0.0.1',
      'dreamsonwheels.herokuapp.com'
  ]
  
  # Application definition
  
  INSTALLED_APPS = [
      'accounts',
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      # Third party apps
      'crispy_forms',
      'django_forms_bootstrap',
      'bootstrap_modal_forms',
      'django_filters',
      'widget_tweaks',
      # Project apps
      'home',
      'products',
      'cart',
      'highlight',
      'posts',
      'checkout',
      'contact',
      'storages',
  ]
  
  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 = 'project.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',
                  'django.template.context_processors.media',
                  'cart.contexts.cart_contents',
              ],
              'builtins': [
                  'crispy_forms.templatetags.crispy_forms_tags',
                  'crispy_forms.templatetags.crispy_forms_field',
              ]
          },
      },
  ]
  
  CRISPY_TEMPLATE_PACK = 'uni_form'
  
  WSGI_APPLICATION = 'project.wsgi.application'
  
  # Database
  # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
  
  
  if "DATABASE_URL" in os.environ:
      print("Postgres in use")
      DATABASES = {
          'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))
      }
  else:
      print("Postgres URL not found, using sqlite3 instead")
      DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
      }
      }
  
  # Password validation
  # https://docs.djangoproject.com/en/3.0/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',
      },
  ]
  
  CRISPY_TEMPLATE_PACK = 'bootstrap4'
  
  MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
  
  # Internationalization
  # https://docs.djangoproject.com/en/3.0/topics/i18n/
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  # Stripe payment platform settings
  
  STRIPE_PUBLISHABLE = os.getenv('STRIPE_PUBLISHABLE')
  STRIPE_SECRET = os.getenv('STRIPE_SECRET')
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/3.0/howto/static-files/
  
  if 'DEBUG' in os.environ:
      print('Using SMPT setting from email backend')
      EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
      DEFAULT_FROM_EMAIL = 'admin@dow.com'
      EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
      EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
      EMAIL_USE_TLS = True
      EMAIL_HOST = os.getenv("EMAIL_HOST")
      EMAIL_PORT = os.getenv("EMAIL_PORT")
  else:
      print('Use console email backend')
      EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
      DEFAULT_FROM_EMAIL = 'admin@dow.com'
      EMAIL_USE_TLS = False
      EMAIL_PORT = 1025
  
  AUTHENTICATION_BACKENDS = [
      'django.contrib.auth.backends.ModelBackend',
      'accounts.backends.EmailAuth',
  ]
  
  STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
  STATIC_URL = '/static/'
  STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
  
  MEDIA_URL = '/media/'
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  
  if 'USE_AWS' in os.environ:
      print("AWS S3 Static File in use.")
      # AWS Settings
      AWS_S3_OBJECT_PARAMETERS = {
          'Expires': 'Thu, 31 Dec 2099 20:00:00 GMT',
          'CacheControl': 'max-age=94608000',
      }
      AWS_STORAGE_BUCKET_NAME = 'dreams-on-wheels'
      AWS_S3_REGION_NAME = 'eu-central-1'
      AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID")
      AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY")
      AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com'
      AWS_DEFAULT_ACL = None
  
      STATICFILES_LOCATION = 'static'
      STATICFILES_STORAGE = 'custom_storages.StaticStorage'
  
      MEDIAFILES_LOCATION = 'media'
      DEFAULT_FILE_STORAGE ='custom_storages.MediaStorage'
  
      STATIC_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{STATICFILES_LOCATION}/'
      MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{MEDIAFILES_LOCATION}/'
  