""" Django settings for WeiBoCrawler project. Generated by 'django-admin startproject' using Django 2.0.13. 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__))) # 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 = '%hx+uaex_$6q@db4tv=ki^5%4d6g=m=h-8g3_ypwrxe13(!p_-' # 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', 'rest_framework', 'CrawKeywords', 'Profile', # The following apps are required: 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'corsheaders', ] 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', 'corsheaders.middleware.CorsMiddleware', ] ROOT_URLCONF = 'WeiBoCrawler.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', 'django.template.context_processors.request', ], }, }, ] # django-allauth基本配置 ACCOUNT_AUTHENTICATION_METHOD = 'username_email' # 可以使用用户名或邮箱登录 ACCOUNT_EMAIL_REQUIRED = True # 必须设置电子邮箱 LOGIN_REDIRECT_URL = '/' # 登录成功后的跳转地址 ACCOUNT_LOGOUT_REDIRECT_URL = '/' # 退出登录后跳转链接 # 发送邮件配置项 # SMTP服务器地址 EMAIL_HOST = 'smtp.exmail.qq.com' # 端口 EMAIL_PORT = 25 # 发送邮件的邮箱 EMAIL_HOST_USER = 'shellmiao@shellmiao.com' # 在邮箱中设置的客户端授权密码 EMAIL_HOST_PASSWORD = 'KU3awdLM2MnDqdbM' EMAIL_USE_TLS = True # 收件人看到的发件人 EMAIL_FROM = 'shellmiao' # 报错此项必须加上 DEFAULT_FROM_EMAIL = 'shellmiao@shellmiao.com' AUTHENTICATION_BACKENDS = [ # Needed to login by username in Django admin, regardless of `allauth` 'django.contrib.auth.backends.ModelBackend', # `allauth` specific authentication methods, such as login by e-mail 'allauth.account.auth_backends.AuthenticationBackend', ] # 注册中邮件验证方法 ACCOUNT_EMAIL_VERIFICATION = "mandatory" # 邮件发送后的冷却时间(以秒为单位) ACCOUNT_EMAIL_CONFIRMATION_COOLDOWN = 180 # 登录尝试失败的次数 ACCOUNT_LOGIN_ATTEMPTS_LIMIT = 5 # 从上次失败的登录尝试,用户被禁止尝试登录的持续时间 ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT = 300 # 电子邮件地址的唯一性 ACCOUNT_UNIQUE_EMAIL = True WSGI_APPLICATION = 'WeiBoCrawler.wsgi.application' # Database # https://docs.djangoproject.com/en/2.0/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'WeiBoCrawler', 'USER': 'crawler', 'PASSWORD': 'Crawler2020520very+', 'HOST': '42.192.54.32', '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', }, ] # allauth SITE_ID = 1 # 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/' REST_FRAMEWORK = { 'DEFAULT_RENDERER_CLASSES': ( 'rest_framework.renderers.BrowsableAPIRenderer', 'rest_framework.renderers.JSONRenderer', ) } # 凡是出现在白名单中的域名,都可以访问后端接口 # 添加 django-cors-headers 的白名单, 使白名单中的 host 可以进行跨域请求 # CORS_ORIGIN_WHITELIST = ( # # 白名单: # "127.0.0.1:3000" # ) CORS_ORIGIN_ALLOW_ALL = True # 所有人 # 允许白名单中的 host 跨域请求时携带 cookie CORS_ALLOW_CREDENTIALS = True