settings.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. """
  2. Django settings for WeiBoCrawler project.
  3. Generated by 'django-admin startproject' using Django 2.0.13.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/2.0/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/2.0/ref/settings/
  8. """
  9. import os
  10. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  11. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  12. # Quick-start development settings - unsuitable for production
  13. # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
  14. # SECURITY WARNING: keep the secret key used in production secret!
  15. SECRET_KEY = '%hx+uaex_$6q@db4tv=ki^5%4d6g=m=h-8g3_ypwrxe13(!p_-'
  16. # SECURITY WARNING: don't run with debug turned on in production!
  17. DEBUG = True
  18. ALLOWED_HOSTS = []
  19. # Application definition
  20. INSTALLED_APPS = [
  21. 'django.contrib.admin',
  22. 'django.contrib.auth',
  23. 'django.contrib.contenttypes',
  24. 'django.contrib.sessions',
  25. 'django.contrib.messages',
  26. 'django.contrib.staticfiles',
  27. 'CrawKeywords',
  28. 'Profile',
  29. # The following apps are required:
  30. 'django.contrib.sites',
  31. 'allauth',
  32. 'allauth.account',
  33. 'allauth.socialaccount',
  34. ]
  35. MIDDLEWARE = [
  36. 'django.middleware.security.SecurityMiddleware',
  37. 'django.contrib.sessions.middleware.SessionMiddleware',
  38. 'django.middleware.common.CommonMiddleware',
  39. 'django.middleware.csrf.CsrfViewMiddleware',
  40. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  41. 'django.contrib.messages.middleware.MessageMiddleware',
  42. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  43. ]
  44. ROOT_URLCONF = 'WeiBoCrawler.urls'
  45. TEMPLATES = [
  46. {
  47. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  48. 'DIRS': [os.path.join(BASE_DIR, 'templates')],
  49. 'APP_DIRS': True,
  50. 'OPTIONS': {
  51. 'context_processors': [
  52. 'django.template.context_processors.debug',
  53. 'django.template.context_processors.request',
  54. 'django.contrib.auth.context_processors.auth',
  55. 'django.contrib.messages.context_processors.messages',
  56. 'django.template.context_processors.request',
  57. ],
  58. },
  59. },
  60. ]
  61. # django-allauth基本配置
  62. ACCOUNT_AUTHENTICATION_METHOD = 'username_email' # 可以使用用户名或邮箱登录
  63. ACCOUNT_EMAIL_REQUIRED = True # 必须设置电子邮箱
  64. LOGIN_REDIRECT_URL = '/' # 登录成功后的跳转地址
  65. ACCOUNT_LOGOUT_REDIRECT_URL = '/' # 退出登录后跳转链接
  66. # 发送邮件配置项
  67. # SMTP服务器地址
  68. EMAIL_HOST = 'smtp.exmail.qq.com'
  69. # 端口
  70. EMAIL_PORT = 25
  71. # 发送邮件的邮箱
  72. EMAIL_HOST_USER = 'shellmiao@shellmiao.com'
  73. # 在邮箱中设置的客户端授权密码
  74. EMAIL_HOST_PASSWORD = 'KU3awdLM2MnDqdbM'
  75. EMAIL_USE_TLS = True
  76. # 收件人看到的发件人
  77. EMAIL_FROM = 'shellmiao<shellmiao@shellmiao.com>'
  78. # 报错此项必须加上
  79. DEFAULT_FROM_EMAIL = 'shellmiao@shellmiao.com'
  80. AUTHENTICATION_BACKENDS = [
  81. # Needed to login by username in Django admin, regardless of `allauth`
  82. 'django.contrib.auth.backends.ModelBackend',
  83. # `allauth` specific authentication methods, such as login by e-mail
  84. 'allauth.account.auth_backends.AuthenticationBackend',
  85. ]
  86. # 注册中邮件验证方法
  87. ACCOUNT_EMAIL_VERIFICATION = "mandatory"
  88. # 邮件发送后的冷却时间(以秒为单位)
  89. ACCOUNT_EMAIL_CONFIRMATION_COOLDOWN = 180
  90. # 登录尝试失败的次数
  91. ACCOUNT_LOGIN_ATTEMPTS_LIMIT = 5
  92. # 从上次失败的登录尝试,用户被禁止尝试登录的持续时间
  93. ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT = 300
  94. # 电子邮件地址的唯一性
  95. ACCOUNT_UNIQUE_EMAIL = True
  96. WSGI_APPLICATION = 'WeiBoCrawler.wsgi.application'
  97. # Database
  98. # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  99. DATABASES = {
  100. 'default': {
  101. 'ENGINE': 'django.db.backends.mysql',
  102. 'NAME': 'WeiBoCrawler',
  103. 'USER': 'crawler',
  104. 'PASSWORD': 'Crawler2020520very+',
  105. 'HOST': '42.192.54.32',
  106. 'PORT': '3306',
  107. }
  108. }
  109. # Password validation
  110. # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
  111. AUTH_PASSWORD_VALIDATORS = [
  112. {
  113. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  114. },
  115. {
  116. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  117. },
  118. {
  119. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  120. },
  121. {
  122. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  123. },
  124. ]
  125. # allauth
  126. SITE_ID = 1
  127. # Internationalization
  128. # https://docs.djangoproject.com/en/2.0/topics/i18n/
  129. LANGUAGE_CODE = 'en-us'
  130. TIME_ZONE = 'UTC'
  131. USE_I18N = True
  132. USE_L10N = True
  133. USE_TZ = True
  134. # Static files (CSS, JavaScript, Images)
  135. # https://docs.djangoproject.com/en/2.0/howto/static-files/
  136. STATIC_URL = '/static/'