text: """
  Django settings for posthog project.
  
  Generated by 'django-admin startproject' using Django 2.2.5.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/2.2/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/2.2/ref/settings/
  """
  
  import os
  import sys
  import dj_database_url
  import sentry_sdk
  from django.core.exceptions import ImproperlyConfigured
  
  from sentry_sdk.integrations.django import DjangoIntegration
  
  
  def get_env(key):
      try:
          return os.environ[key]
      except KeyError:
          raise ImproperlyConfigured(f'The environment var "{key}" is absolutely required to run this software')
  
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  
  DEBUG = os.environ.get("DEBUG", False)
  TEST = 'test' in sys.argv
  
  SITE_URL = os.environ.get('SITE_URL', 'http://localhost:8000')
  
  if not DEBUG and not TEST:
      SECURE_SSL_REDIRECT = True
      SESSION_COOKIE_SECURE = True
      if os.environ.get('SENTRY_DSN'):
          sentry_sdk.init(
              dsn=os.environ['SENTRY_DSN'],
              integrations=[DjangoIntegration()]
          )
  
  if os.environ.get('DISABLE_SECURE_SSL_REDIRECT'):
      SECURE_SSL_REDIRECT = False
  
  if os.environ.get('IS_BEHIND_PROXY', False):
      USE_X_FORWARDED_HOST = True
      SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
  
  # Quick-start development settings - unsuitable for production
  # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = os.environ.get('SECRET_KEY', "6(@hkxrx07e*z3@6ls#uwajz6v@#8-%mmvs8-_y7c_c^l5c0m$")
  
  # SECURITY WARNING: don't run with debug turned on in production!
  
  ALLOWED_HOSTS = [
      '*'
  ]
  
  
  # Application definition
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'posthog.apps.PostHogConfig',
      'rest_framework',
      'loginas',
      'corsheaders'
  ]
  
  MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'corsheaders.middleware.CorsMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
      'whitenoise.middleware.WhiteNoiseMiddleware',
  ]
  CORS_ORIGIN_ALLOW_ALL = True
  
  ROOT_URLCONF = 'posthog.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': ['frontend/dist'],
          '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 = 'posthog.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
  
  if TEST or DEBUG:
      DATABASE_URL = os.environ.get('DATABASE_URL', 'postgres://localhost:5432/posthog')
  else:
      DATABASE_URL = get_env('DATABASE_URL')
  DATABASES = {
      'default': dj_database_url.config(default=DATABASE_URL, conn_max_age=600)
  }
  
  # Password validation
  # https://docs.djangoproject.com/en/2.2/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/2.2/topics/i18n/
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/2.2/howto/static-files/
  
  STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
  STATIC_URL = '/static/'
  STATICFILES_DIRS = [
      os.path.join(BASE_DIR, 'frontend/dist'),
  ]
  STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  
  AUTH_USER_MODEL = 'posthog.User'
  
  LOGIN_URL = '/login'
  LOGOUT_URL = '/logout'
  LOGIN_REDIRECT_URL = '/'
  APPEND_SLASH = False
  CORS_URLS_REGEX = r'^/api/.*$'
  
  REST_FRAMEWORK = {
      'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
      'PAGE_SIZE': 100,
      'DEFAULT_PERMISSION_CLASSES': [
          'rest_framework.permissions.IsAuthenticated',
      ]
  }
  
  # You can pass a comma deliminated list of domains with which users can sign up to this service
  RESTRICT_SIGNUPS = os.environ.get('RESTRICT_SIGNUPS', False)
  
  if os.environ.get('INCLUDE_DOCS', False):
      INCLUDE_API_DOCS = True
      INSTALLED_APPS.append('drf_yasg')