text: """
  Django settings for VueDjangoShopWebsite project.
  
  Generated by 'django-admin startproject' using Django 3.0.
  
  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 os
  import sys
  from datetime import timedelta
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  from past.builtins import execfile
  
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  sys.path.insert(0, BASE_DIR)
  sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
  sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))
  
  # 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 = '4x_=dj($maxn@i+@^k_w=td=i%t=7424trg80aube_8f-%0sb('
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = True
  
  ALLOWED_HOSTS = ["*"]
  
  # 此处重载是为了使我们的UserProfile生效
  AUTH_USER_MODEL = "users.UserProfile"
  
  # Application definition
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'django_filters',
      'corsheaders',
      'crispy_forms',
      'xadmin',
      'rest_framework',
      'rest_framework.authtoken',
      'DjangoUeditor',
      'users.apps.UsersConfig',
      'goods.apps.GoodsConfig',
      'trade.apps.TradeConfig',
      'user_operation.apps.UserOperationConfig',
      'social_django',
  ]
  
  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',
  ]
  
  # 跨域增加忽略
  CORS_ALLOW_CREDENTIALS = True
  CORS_ORIGIN_ALLOW_ALL = True
  CORS_ORIGIN_WHITELIST = (
      'http://localhost:3000',
      'http://localhost:8000',
      'http://localhost:8080',
  )
  
  CORS_ALLOW_METHODS = (
      'DELETE',
      'GET',
      'OPTIONS',
      'PATCH',
      'POST',
      'PUT',
      'VIEW',
  )
  
  CORS_ALLOW_HEADERS = (
      'XMLHttpRequest',
      'X_FILENAME',
      'accept-encoding',
      'authorization',
      'content-type',
      'dnt',
      'origin',
      'user-agent',
      'x-csrftoken',
      'x-requested-with',
      'Pragma',
  )
  
  ROOT_URLCONF = 'VueDjangoShopWebsite.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [os.path.join(BASE_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',
                  'social_django.context_processors.backends',
                  'social_django.context_processors.login_redirect',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'VueDjangoShopWebsite.wsgi.application'
  
  # Database
  # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
  
  # DATABASES = {
  #     'default': {
  #         'ENGINE': 'django.db.backends.mysql',
  #         'NAME': 'vuedjango',
  #         'USER': 'root',
  #         'PASSWORD': 'gongziran',
  #         'HOST': '127.0.0.1',
  #         "OPTIONS": {"init_command": "SET default_storage_engine=INNODB;"}
  #     }
  # }
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
      }
  }
  
  # Password validation
  # https://docs.djangoproject.com/en/3.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/3.0/topics/i18n/
  
  # 语言改为中文
  LANGUAGE_CODE = 'zh-hans'
  
  # 时区改为上海
  TIME_ZONE = 'Asia/Shanghai'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = False
  
  # 设置使用自定义的认证后端进行用户认证
  AUTHENTICATION_BACKENDS = (
      'users.views.CustomBackend',
      'social_core.backends.qq.QQOAuth2',
      'social_core.backends.weibo.WeiboOAuth2',
      'social_core.backends.weixin.WeixinOAuth2',
      'django.contrib.auth.backends.ModelBackend',
  )
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/3.0/howto/static-files/
  
  STATIC_URL = '/static/'
  STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"), ]
  
  MEDIA_URL = "/media/"
  MEDIA_ROOT = os.path.join(BASE_DIR, "media")
  
  # 所有drf相关的设置
  REST_FRAMEWORK = {
      'DEFAULT_AUTHENTICATION_CLASSES': (
          'rest_framework.authentication.BasicAuthentication',
          'rest_framework.authentication.SessionAuthentication',
      ),
      'DEFAULT_THROTTLE_CLASSES': (
          'rest_framework.throttling.AnonRateThrottle',
          'rest_framework.throttling.UserRateThrottle'
      ),
      'DEFAULT_THROTTLE_RATES': {
          'anon': '100/day',
          'user': '1000/day'
      },
      'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
  }
  
  SIMPLE_JWT = {
      'ACCESS_TOKEN_LIFETIME': timedelta(days=7),
      'REFRESH_TOKEN_LIFETIME': timedelta(days=7),
      'AUTH_HEADER_TYPES': ('Bearer',),
  }
  
  # 手机号码正则表达式
  REGEX_MOBILE = "^1[358]\d{9}$|^147\d{8}$|^176\d{8}$"
  
  # 云片网设置
  APIKEY = ''
  
  # 腾讯云短信设置
  TENCENT_SECRET_ID = ''
  TENCENT_SECRET_KEY = ''
  
  # 支付宝相关的key路径
  private_key_path = os.path.join(BASE_DIR, 'apps/trade/keys/private_2048.txt')
  ali_pub_key_path = os.path.join(BASE_DIR, 'apps/trade/keys/alipay_key_2048.txt')
  
  # 缓存过期时间
  REST_FRAMEWORK_EXTENSIONS = {
      'DEFAULT_CACHE_RESPONSE_TIMEOUT': 60 * 5
  }
  
  # 配置redis缓存
  # CACHES = {
  #     "default": {
  #         "BACKEND": "django_redis.cache.RedisCache",
  #         "LOCATION": "redis://127.0.0.1:6379/",
  #         "OPTIONS": {
  #             "CLIENT_CLASS": "django_redis.client.DefaultClient",
  #             "PASSWORD": "password"
  #         }
  #     }
  # }
  
  SOCIAL_AUTH_WEIBO_KEY = ''
  SOCIAL_AUTH_WEIBO_SECRET = ''
  SOCIAL_AUTH_QQ_KEY = ''
  SOCIAL_AUTH_QQ_SECRET = ''
  SOCIAL_AUTH_WEIXIN_KEY = ''
  SOCIAL_AUTH_WEIXIN_SECRET = ''
  
  SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/index/'
  
  # 引入本地配置
  try:
      from .local_settings import *
  except ModuleNotFoundError as e:
      pass
  