text: """
  Django settings for example project.
  
  Generated by 'django-admin startproject' using Django 2.0.8.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/2.0/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/2.0/ref/settings/
  """
  
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  import os
  
  from wagtail import VERSION as WAGTAIL_VERSION
  
  
  PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  BASE_DIR = os.path.dirname(PROJECT_DIR)
  
  
  # Quick-start development settings - unsuitable for production
  # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
  
  
  # Application definition
  
  INSTALLED_APPS = [
      "home",
      "images",
      "documents",
      "search",
      "wagtail.contrib.forms",
      "wagtail.contrib.redirects",
      "wagtail.embeds",
      "wagtail.sites",
      "wagtail.users",
      "wagtail.snippets",
      "wagtail.documents",
      "wagtail.images",
      "wagtail.search",
      "wagtail.admin",
      "wagtail.core",
      "wagtail.contrib.settings",
      "modelcluster",
      "wagtailmedia",
      "taggit",
      "django.contrib.admin",
      "django.contrib.auth",
      "django.contrib.contenttypes",
      "django.contrib.sessions",
      "django.contrib.messages",
      "django.contrib.staticfiles",
      "corsheaders",
      "wagtail_headless_preview",
      # GRAPPLE SPECIFIC MODULES
      "grapple",
      "graphene_django",
  ]
  
  MIDDLEWARE = [
      "corsheaders.middleware.CorsMiddleware",
      "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",
      "django.middleware.security.SecurityMiddleware",
  ]
  
  if WAGTAIL_VERSION < (2, 9):
      MIDDLEWARE += ["wagtail.core.middleware.SiteMiddleware"]
  
  MIDDLEWARE += ["wagtail.contrib.redirects.middleware.RedirectMiddleware"]
  
  ROOT_URLCONF = "example.urls"
  
  TEMPLATES = [
      {
          "BACKEND": "django.template.backends.django.DjangoTemplates",
          "DIRS": [os.path.join(PROJECT_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 = "example.wsgi.application"
  
  
  # Database
  # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  
  DATABASES = {
      "default": {
          "ENGINE": "django.db.backends.sqlite3",
          "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
      }
  }
  
  
  # Password validation
  # https://docs.djangoproject.com/en/2.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"},
  ]
  
  
  # Internationalization
  # https://docs.djangoproject.com/en/2.0/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.0/howto/static-files/
  
  STATICFILES_FINDERS = [
      "django.contrib.staticfiles.finders.FileSystemFinder",
      "django.contrib.staticfiles.finders.AppDirectoriesFinder",
  ]
  
  STATICFILES_DIRS = [os.path.join(PROJECT_DIR, "static")]
  
  # ManifestStaticFilesStorage is recommended in production, to prevent outdated
  # Javascript / CSS assets being served from cache (e.g. after a Wagtail upgrade).
  # See https://docs.djangoproject.com/en/2.0/ref/contrib/staticfiles/#manifeststaticfilesstorage
  STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
  
  STATIC_ROOT = os.path.join(BASE_DIR, "static")
  STATIC_URL = "/static/"
  
  MEDIA_ROOT = os.path.join(BASE_DIR, "media")
  MEDIA_URL = "/media/"
  
  
  # Wagtail settings
  
  WAGTAIL_SITE_NAME = "example"
  WAGTAILIMAGES_IMAGE_MODEL = "images.CustomImage"
  WAGTAILDOCS_DOCUMENT_MODEL = "documents.CustomDocument"
  WAGTAILDOCS_SERVE_METHOD = "serve_view"
  
  # https://github.com/wagtail/wagtail/issues/6656#issuecomment-749711713
  if WAGTAIL_VERSION < (2, 11):
      WAGTAILEMBEDS_FINDERS = [
          {
              "class": "wagtail.embeds.finders.oembed",
              "providers": [
                  {
                      "endpoint": "https://www.youtube.com/oembed",
                      "urls": [
                          r"^https?://(?:[-\w]+\.)?youtube\.com/watch.+$",
                          r"^https?://(?:[-\w]+\.)?youtube\.com/v/.+$",
                          r"^https?://youtu\.be/.+$",
                          r"^https?://(?:[-\w]+\.)?youtube\.com/user/.+$",
                          r"^https?://(?:[-\w]+\.)?youtube\.com/[^#?/]+#[^#?/]+/.+$",
                          r"^https?://m\.youtube\.com/index.+$",
                          r"^https?://(?:[-\w]+\.)?youtube\.com/profile.+$",
                          r"^https?://(?:[-\w]+\.)?youtube\.com/view_play_list.+$",
                          r"^https?://(?:[-\w]+\.)?youtube\.com/playlist.+$",
                      ],
                  }
              ],
              "options": {"scheme": "https"},
          },
          {
              "class": "wagtail.embeds.finders.oembed",
          },
      ]
  
  # Base URL to use when referring to full URLs within the Wagtail admin backend -
  # e.g. in notification emails. Don't include '/admin' or a trailing slash
  BASE_URL = "http://localhost:8000"
  
  CORS_ORIGIN_ALLOW_ALL = True
  
  # Grapple Config:
  GRAPHENE = {"SCHEMA": "grapple.schema.schema"}
  GRAPPLE = {
      "APPS": ["images", "home", "documents"],
      "ADD_SEARCH_HIT": True,
  }
  
  HEADLESS_PREVIEW_CLIENT_URLS = {"default": "http://localhost:8001/preview"}
  HEADLESS_PREVIEW_LIVE = True
  
  try:
      from channels.asgi import get_channel_layer  # noqa
  
      INSTALLED_APPS += ["channels"]
      ASGI_APPLICATION = "asgi.channel_layer"
      CHANNELS_WS_PROTOCOLS = ["graphql-ws"]
  
      CHANNEL_LAYERS = {
          "default": {
              # "BACKEND": "asgi_redis.RedisChannelLayer",
              "BACKEND": "asgiref.inmemory.ChannelLayer",
              "ROUTING": "grapple.urls.channel_routing",
          }
      }
  except ImportError:
      pass
  