text: """
  Django settings for config project.
  """
  
  import environ
  
  import os
  import sys
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')
  sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
  sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))
  ROOT_DIR = environ.Path(__file__) - 3
  APPS_DIR = ROOT_DIR.path('project')
  env = environ.Env()
  
  READ_DOT_ENV_FILE = env.bool('DJANGO_READ_DOT_ENV_FILE', default=False)
  
  if READ_DOT_ENV_FILE:
      env_file = str(ROOT_DIR.path('.env'))
      print('Loading : {}' .format(env_file))
      env.read_env(env_file)
      print('The .env file has been loaded. See base.py for more information')
  
  DEBUG = env.bool('DJANGO_DEBUG', False)
  
  
  # Application definition
  
  DJANGO_APPS = (
      "xadmin",
      'crispy_forms',
      'reversion',
      'bootstrap_admin',  #一定要放在`django.contrib.admin`前面
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'django.contrib.sites',
  )
  
  THIRD_PARTY_APPS = (
      'rest_framework',
      'rest_framework.authtoken',
      'rest_auth',
      'allauth',
      'allauth.account',
      'rest_auth.registration',
      'drf_yasg',  # 自动生成docs
      'rest_framework_swagger',
      'corsheaders',
      'django_filters',
      'captcha',
      'pure_pagination',
      'DjangoUeditor',
  )
  
  LOCAL_APPS = (
      'api',
      'apps.users',
      'apps.schedules',
      'apps.notes',
      'apps.habits',
      'apps.course',
      'apps.operation',
      'apps.organization',
  )
  
  INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
  
  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 = 'timecat.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [TEMPLATE_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',
                  #添加图片处理器，为了在课程列表中前面加上MEDIA_URL
                  'django.template.context_processors.media',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'timecat.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': str(ROOT_DIR.path('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 = 'zh-hans'
  
  TIME_ZONE = 'Asia/Shanghai'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  
  # Static files (CSS, JavaScript, Images)
  
  STATIC_URL = '/static/'
  STATICFILES_DIRS = (os.path.join(BASE_DIR,'static'),)
  STATIC_ROOT = str(ROOT_DIR('staticfiles'))
  STATICFILES_FINDERS = (
      'django.contrib.staticfiles.finders.FileSystemFinder',
      'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  )
  
  # 设置上传文件的路径
  MEDIA_URL = '/media/'
  MEDIA_ROOT = os.path.join(BASE_DIR,'media')   #指定根目录
  
  # LOGIN_URL = '/login/'
  
  
  # REST framework config
  
  REST_FRAMEWORK = {
      'DEFAULT_AUTHENTICATION_CLASSES': (
          'rest_framework.authentication.TokenAuthentication',
          'rest_framework.authentication.SessionAuthentication',
      ),
      'DEFAULT_PERMISSION_CLASSES': (
          'rest_framework.permissions.IsAuthenticated',
      ),
      'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),
      # 'DEFAULT_RENDERER_CLASSES': (
      #     'rest_framework_csv.renderers.CSVRenderer',
      # ),
  }
  
  
  SWAGGER_SETTINGS = {
      'SECURITY_DEFINITIONS': {
          'api_key': {
              'type': 'apiKey',
              'in': 'header',
              'name': 'Authorization'
          }
      },
  }
  
  LOGIN_URL = 'rest_framework:login'
  LOGOUT_URL = 'rest_framework:logout'
  
  # 自定义用户模型 custom user model
  AUTH_USER_MODEL = 'users.CustomUser'
  AUTHENTICATION_BACKENDS = (
      'apps.users.views.CustomBackend',
  )
  
  EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  
  SITE_ID = 1
  