settings.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. """
  2. Django settings for st_cloud project.
  3. Generated by 'django-admin startproject' using Django 3.2.7.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/3.2/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/3.2/ref/settings/
  8. """
  9. from pathlib import Path
  10. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  11. BASE_DIR = Path(__file__).resolve().parent.parent
  12. # Quick-start development settings - unsuitable for production
  13. # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
  14. # SECURITY WARNING: keep the secret key used in production secret!
  15. SECRET_KEY = 'django-insecure-h1r^p(6-s&@7u!q(sv%_@97fxv(ikbi7d9p#i9+-o_3&pbpw(j'
  16. SALT = 'sa0v-038auwmd-r0awvy4-0y4vs9mdy9-aby09384vy-amr9tv8ybsva9v4y'
  17. # SECURITY WARNING: don't run with utils turned on in production!
  18. DEBUG = True
  19. ALLOWED_HOSTS = ['30gz758467.51vip.biz', '127.0.0.1']
  20. # Application definition
  21. INSTALLED_APPS = [
  22. 'django.contrib.admin',
  23. 'django.contrib.auth',
  24. 'django.contrib.contenttypes',
  25. 'django.contrib.sessions',
  26. 'django.contrib.messages',
  27. 'django.contrib.staticfiles',
  28. 'rest_framework',
  29. 'corsheaders',
  30. 'group',
  31. 'folder',
  32. 'file',
  33. 'account'
  34. ]
  35. MIDDLEWARE = [
  36. 'corsheaders.middleware.CorsMiddleware',
  37. 'django.middleware.security.SecurityMiddleware',
  38. 'django.contrib.sessions.middleware.SessionMiddleware',
  39. 'django.middleware.common.CommonMiddleware',
  40. # 'django.middleware.csrf.CsrfViewMiddleware',
  41. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  42. 'django.contrib.messages.middleware.MessageMiddleware',
  43. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  44. ]
  45. ROOT_URLCONF = 'st_cloud.urls'
  46. TEMPLATES = [
  47. {
  48. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  49. 'DIRS': [BASE_DIR / 'templates']
  50. ,
  51. 'APP_DIRS': True,
  52. 'OPTIONS': {
  53. 'context_processors': [
  54. 'django.template.context_processors.debug',
  55. 'django.template.context_processors.request',
  56. 'django.contrib.auth.context_processors.auth',
  57. 'django.contrib.messages.context_processors.messages',
  58. ],
  59. },
  60. },
  61. ]
  62. WSGI_APPLICATION = 'st_cloud.wsgi.application'
  63. # Database
  64. # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
  65. DATABASES = {
  66. 'default': {
  67. 'ENGINE': 'django.db.backends.sqlite3',
  68. 'NAME': BASE_DIR / 'db.sqlite3',
  69. }
  70. }
  71. # Password validation
  72. # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
  73. PASSWORD_RESET_TIMEOUT = 360000
  74. AUTH_PASSWORD_VALIDATORS = [
  75. {
  76. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  77. },
  78. {
  79. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  80. },
  81. {
  82. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  83. },
  84. {
  85. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  86. },
  87. ]
  88. # Internationalization
  89. # https://docs.djangoproject.com/en/3.2/topics/i18n/
  90. LANGUAGE_CODE = 'en-us'
  91. TIME_ZONE = 'UTC'
  92. USE_I18N = True
  93. USE_L10N = True
  94. USE_TZ = True
  95. # Static files (CSS, JavaScript, Images)
  96. # https://docs.djangoproject.com/en/3.2/howto/static-files/
  97. STATIC_URL = '/static/'
  98. # Default primary key field type
  99. # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
  100. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  101. EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  102. EMAIL_USE_TLS = True
  103. EMAIL_HOST = 'smtp.qq.com'
  104. EMAIL_PORT = 25
  105. EMAIL_HOST_USER = 'lin-xinyuan@qq.com'
  106. EMAIL_HOST_PASSWORD = 'terwmysqpvxaeahe'
  107. DEFAULT_FROM_EMAIL = f'ST网盘 <{EMAIL_HOST_USER}>'
  108. CORS_ORIGIN_ALLOW_ALL = True
  109. CORS_ALLOW_CREDENTIALS = True
  110. # 跨域允许的请求方式,可以使用默认值,默认的请求方式为:
  111. # from corsheaders.defaults import default_methods
  112. CORS_ALLOW_METHODS = (
  113. 'GET',
  114. 'POST',
  115. 'PUT',
  116. 'PATCH',
  117. 'DELETE',
  118. 'OPTIONS'
  119. )
  120. # 允许跨域的请求头,可以使用默认值,默认的请求头为:
  121. # from corsheaders.defaults import default_headers
  122. # CORS_ALLOW_HEADERS = default_headers
  123. CORS_ALLOW_HEADERS = (
  124. 'XMLHttpRequest',
  125. 'X_FILENAME',
  126. 'accept-encoding',
  127. 'authorization',
  128. 'content-type',
  129. 'dnt',
  130. 'origin',
  131. 'user-agent',
  132. 'x-csrftoken',
  133. 'x-requested-with',
  134. 'Pragma',
  135. )
  136. # 跨域请求时,是否运行携带cookie,默认为False
  137. CORS_ALLOW_CREDENTIALS = True
  138. # 允许所有主机执行跨站点请求,默认为False
  139. # 如果没设置该参数,则必须设置白名单,运行部分白名单的主机才能执行跨站点请求
  140. CORS_ORIGIN_ALLOW_ALL = True