text: """
  Django settings for foodgram project.
  Generated by 'django-admin startproject' using Django 3.0.5.
  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 sentry_sdk
  from sentry_sdk.integrations.django import DjangoIntegration
  import os
  from django.core.management.utils import get_random_secret_key
  import environ
  env = environ.Env()
  environ.Env.read_env()
  
  sentry_sdk.init(
      dsn = 'https://a9d50c03ce364238b88d703cd50c3ea4@o543343.ingest.sentry.io/5663411', # noqa
      integrations=[DjangoIntegration()],
      # Set traces_sample_rate to 1.0 to capture 100%
      # of transactions for performance monitoring.
      # We recommend adjusting this value in production,
      traces_sample_rate=1.0,
  
      # If you wish to associate users to errors (assuming you are using
      # django.contrib.auth) you may enable sending PII data.
      send_default_pii=True,
  
      # By default the SDK will try to use the SENTRY_RELEASE
      # environment variable, or infer a git commit
      # SHA as release, however you may want to set
      # something more human-readable.
      # release="myapp@1.0.0",
  )
  
  # 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_DJ', default=get_random_secret_key())
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = bool(int(os.environ.get("DEBUG") if os.environ.get("DEBUG") else "0"))
  
  ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS').split(' ')
  
  PAGINATE_BY = 6
  
  # Application definition
  
  INSTALLED_APPS = [
      'users',
      'recipes',
      'api',
      "debug_toolbar",
      'django.contrib.sites',
      'django.contrib.flatpages',
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'django.contrib.postgres',
      'sorl.thumbnail',
      'django_filters',
      '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',
      'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
      "debug_toolbar.middleware.DebugToolbarMiddleware",
  ]
  
  ROOT_URLCONF = 'foodgram.urls'
  
  TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [TEMPLATES_DIR],
          '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',
              ],
              'libraries':{
                  'changing_endings_word_filter': 'recipes.templatetags.changing_endings_word_filter', # noqa
                  'checking_status_filter': 'recipes.templatetags.checking_status_filter', # noqa
                  'tags_filter': 'recipes.templatetags.tags_filter',
                  'addclass_html_filter': 'users.templatetags.addclass_html_filter',      # noqa
              }
          },
      },
  ]
  
  WSGI_APPLICATION = 'foodgram.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
  
  if DEBUG:
      DATABASES = {
          'default': env.db()}
  else:
      DATABASES = {
          'default': {
              'ENGINE': 'django.db.backends.postgresql',
              'NAME': os.environ.get('POSTGRES_DB'),
              'USER': os.environ.get('POSTGRES_USER'),
              'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),
              'HOST': os.environ.get('DB_HOST'),
              'PORT': os.environ.get('DB_PORT')}}
  
  # Password validation
  # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
  
  AUTH_PASSWORD_VALIDATORS = [
      {
          'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', # noqa
      },
      {
          'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', # noqa
      },
      {
          'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', # noqa
      },
      {
          'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', # noqa
      },
  ]
  
  
  # Internationalization
  # https://docs.djangoproject.com/en/3.0/topics/i18n/
  
  LANGUAGE_CODE = 'ru'
  LANGUAGES = (
      ('ru', 'Russian'),
      ('en', 'English'),
  )
  
  LOCALE_PATHS = (
      'locale',
      # os.path.join(PROJECT_DIR, 'locale'),
  )
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/3.0/howto/static-files/
  
  
  if DEBUG:
      STATICFILES_DIRS = [
          os.path.join(BASE_DIR, 'static')]
  else:
      STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  
  STATIC_URL = '/static/'
  MEDIA_URL = '/media/'
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  LOGIN_URL = '/auth/login/'
  LOGIN_REDIRECT_URL = 'index'
  CORS_ORIGIN_ALLOW_ALL = True
  
  if DEBUG:
      EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
      EMAIL_FILE_PATH = os.path.join(BASE_DIR, 'sent_emails')
  else:
      EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
      ACCOUNT_ACTIVATION_DAYS = 7
      EMAIL_HOST = os.environ.get('EMAIL_HOST')
      EMAIL_PORT = int(os.environ.get('EMAIL_PORT'))
      EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
      EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
      EMAIL_USE_TLS = False
      EMAIL_USE_SSL = True
      SERVER_EMAIL = EMAIL_HOST_USER
      DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
      ADMINS = (
          (EMAIL_HOST_USER, SERVER_EMAIL),)
      MANAGERS = ADMINS
  
  SITE_ID = 1
  
  
  INTERNAL_IPS = [
      "127.0.0.1",
  ]
  APPEND_SLASH = False
  