187 lines
5.1 KiB
Python
187 lines
5.1 KiB
Python
"""
|
||
Django settings for pwdselfservice project.
|
||
|
||
Generated by 'django-admin startproject' using Django 2.1.8.
|
||
|
||
For more information on this file, see
|
||
https://docs.djangoproject.com/en/2.1/topics/settings/
|
||
|
||
For the full list of settings and their values, see
|
||
https://docs.djangoproject.com/en/2.1/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.1/howto/deployment/checklist/
|
||
|
||
# SECURITY WARNING: keep the secret key used in production secret!
|
||
SECRET_KEY = 'nxnm3#&2tat_c2i6%$y74a)t$(3irh^gpwaleoja1kdv30fmcm'
|
||
|
||
# SECURITY WARNING: don't run with debug turned on in production!
|
||
DEBUG = False
|
||
|
||
ALLOWED_HOSTS = ['*']
|
||
|
||
# 创建日志的路径
|
||
LOG_PATH = os.path.join(BASE_DIR, 'log')
|
||
# 如果地址不存在,则会自动创建log文件夹
|
||
if not os.path.isdir(LOG_PATH):
|
||
os.mkdir(LOG_PATH)
|
||
|
||
LOGGING = {
|
||
'version': 1,
|
||
'disable_existing_loggers': False,#此选项开启表示禁用部分日志,不建议设置为True
|
||
'formatters': {
|
||
'verbose': {
|
||
'format': '%(asctime)s %(levelname)s %(pathname)s %(module)s.%(funcName)s %(lineno)d: %(message)s'
|
||
#日志格式
|
||
},
|
||
'simple': {
|
||
'format': '%(asctime)s %(levelname)s %(pathname)s %(module)s.%(funcName)s %(lineno)d: %(message)s'
|
||
},
|
||
},
|
||
'filters': {
|
||
'require_debug_true': {
|
||
'()': 'django.utils.log.RequireDebugTrue',#过滤器,只有当setting的DEBUG = True时生效
|
||
},
|
||
},
|
||
'handlers': {
|
||
'console': {
|
||
'level': 'DEBUG',
|
||
'filters': ['require_debug_true'],
|
||
'class': 'logging.StreamHandler',
|
||
'formatter': 'verbose'
|
||
},
|
||
'file': {#重点配置部分
|
||
'level': 'DEBUG',
|
||
'class': 'logging.FileHandler',
|
||
'filename': '%s/log.log' % LOG_PATH,#日志保存文件
|
||
'formatter': 'verbose'#日志格式,与上边的设置对应选择
|
||
}
|
||
},
|
||
'loggers': {
|
||
'django': {#日志记录器
|
||
'handlers': ['file'],
|
||
'level': 'DEBUG',
|
||
'propagate': True,
|
||
}
|
||
},
|
||
}
|
||
|
||
|
||
# SESSION
|
||
# 只有在settings.SESSION_SAVE_EVERY_REQUEST 为True时才有效
|
||
SESSION_SAVE_EVERY_REQUEST = True
|
||
# 过期时间分钟
|
||
SESSION_COOKIE_AGE = 300
|
||
# False 会话cookie可以在用户浏览器中保持有效期。True:关闭浏览器,则Cookie失效。
|
||
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
||
# 建议配置,阻止 javascript 对会话数据的访问,提高安全性。
|
||
# SESSION_COOKIE_HTTPONLY= True
|
||
|
||
|
||
# Application definition
|
||
|
||
INSTALLED_APPS = [
|
||
# 'django.contrib.admin',
|
||
'django.contrib.auth',
|
||
'django.contrib.contenttypes',
|
||
'django.contrib.sessions',
|
||
'django.contrib.messages',
|
||
'django.contrib.staticfiles',
|
||
'resetpwd',
|
||
]
|
||
|
||
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 = 'pwdselfservice.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',
|
||
],
|
||
},
|
||
},
|
||
]
|
||
|
||
WSGI_APPLICATION = 'pwdselfservice.wsgi.application'
|
||
|
||
|
||
# Database
|
||
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
|
||
|
||
# DATABASES = {
|
||
# 'default': {
|
||
# 'ENGINE': 'django.db.backends.sqlite3',
|
||
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||
# }
|
||
# }
|
||
|
||
|
||
# Password validation
|
||
# https://docs.djangoproject.com/en/2.1/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.1/topics/i18n/
|
||
|
||
LANGUAGE_CODE = 'zh-hans'
|
||
|
||
TIME_ZONE = 'Asia/Shanghai'
|
||
|
||
USE_I18N = True
|
||
|
||
USE_L10N = True
|
||
|
||
USE_TZ = False
|
||
|
||
|
||
# Static files (CSS, JavaScript, Images)
|
||
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||
|
||
STATIC_URL = '/static/'
|
||
STATIC_ROOT = 'static'
|
||
|
||
STATICFILES_DIRS = [
|
||
os.path.join(BASE_DIR, 'static'),
|
||
]
|
||
|