text: """
  Django settings for backend project.
  
  Generated by 'django-admin startproject' using Django 2.0.
  
  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/
  """
  
  import os
  
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 即项目的根目录
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  
  USE_PROXY = False
  
  # Quick-start development settings - unsuitable for production
  # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = '*-eih^1a=^1qf%%b*xovqupe!$au3t6awv!(vnr-nt=&pi$g8w'
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = True
  
  ALLOWED_HOSTS = []
  
  
  # Application definition
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
  
      # 新应用
      'apis.apps.ApisConfig',
      'authorization.apps.AuthorizationConfig'
  ]
  
  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 = 'backend.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [],
          '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 = 'backend.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'),
      },
      'slave': {
          'ENGINE': 'django.db.backends.mysql',
          'NAME': 'backend',
          'USER': 'root',
          'PASSWORD': '279279',
          'HOST': '127.0.0.1',
          'PORT': '3306'
      }
  }
  """
  
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.mysql',
          'NAME': 'backend',
          'USER': 'root',
          'PASSWORD': '279279',
          'HOST': '127.0.0.1',
          'PORT': '3306'
      }
  }
  
  
  
  
  # 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/
  
  STATIC_URL = '/static/'
  
  RESOURCES_DIR = os.path.join(BASE_DIR, 'resources')
  IMAGES_DIR = os.path.join(RESOURCES_DIR, 'images')
  
  # app secret 由开发者在微信官网开发者页面生成的
  WX_APP_SECRET = 'a63eeef7a49fe40ef79e881b3a6fa141'
  
  # session 超时时间(单位为s，此时配置session过期时长为10分钟)
  SESSION_COOKIE_AGE = 60*10
  
  LOG_DIR = os.path.join(BASE_DIR, 'log')
  if not os.path.exists(LOG_DIR):
      os.makedirs(LOG_DIR)
  
  LOGGING = {
  
      # 版本配置
      'version': 1,
  
      # 日志格式
      'formatters': {
          'standard': {
              'format': '%(asctime)s [%(threadName)s: %(thread)d]'
                        '%(pathname)s:%(funcName)s:%(lineno)d %(levelname)s - %(message)s'
          }
      },
  
      # 自定义过滤器的实现 （test为过滤器的名字）
      'filters': {
          'test': {
              '()': 'ops.TestFilter'
          }
      },
  
      # 配置处理器
      'handlers': {
  
          # 终端处理器
  
          'console_handler': {
              'level': 'INFO',
              'class': 'logging.StreamHandler',
              'formatter': 'standard'
          },
  
          # 文件处理器
  
          'file_handler': {
              'level': 'DEBUG',
              'class': 'logging.handlers.RotatingFileHandler',
              'filename': os.path.join(LOG_DIR, 'backend.log'),
              'maxBytes': 1024*1024*1024,
              'backupCount': 5,
              'formatter': 'standard',
              'encoding': 'utf-8'
          }
      },
  
      # 日志实例
      'loggers': {
          'django': {
              'handlers': ['console_handler', 'file_handler'],
              'filters': ['test'],
              'level': 'DEBUG'
          }
      }
  }
  
  
  # 缓存
  CACHES = {
      'default': {
          # 1. MemCache
          # 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
          # 'LOCATION': '127.0.0.1:11211',
  
          # 2. DB Cache
          # 'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
          # 'LOCATION': 'my_cache_table',
  
          # 3. Filesystem Cache
          # 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
          # 'LOCATION': '/var/tmp/django_cache',
  
          # 4. Local Mem Cache （基于内存的缓存）
          'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
          'LOCATION': 'backend-cache'
      }
  }