|
|
|
"""
|
|
|
|
Django settings for YY_RMS_Multiple_Manage project.
|
|
|
|
|
|
|
|
Generated by 'django-admin startproject' using Django 2.2.
|
|
|
|
|
|
|
|
For more information on this file, see
|
|
|
|
https://docs.djangoproject.com/en/2.2/topics/settings/
|
|
|
|
|
|
|
|
For the full list of settings and their values, see
|
|
|
|
https://docs.djangoproject.com/en/2.2/ref/settings/
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from Common.searchDrug import GetDrugTypeData
|
|
|
|
|
|
|
|
# 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.2/howto/deployment/checklist/
|
|
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
|
|
SECRET_KEY = '%xoxlv+gx&4$^t8a2nyj56g93ayt-_xl_zl^dy3oru8o)3-r1k'
|
|
|
|
|
|
|
|
# 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',
|
|
|
|
|
|
|
|
# 'corsheaders',
|
|
|
|
'account',
|
|
|
|
'user'
|
|
|
|
]
|
|
|
|
|
|
|
|
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',
|
|
|
|
|
|
|
|
'user.login_required.LoginRequiredMiddleware',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# 跨域增加忽略
|
|
|
|
CORS_ALLOW_CREDENTIALS = True
|
|
|
|
CORS_ORIGIN_ALLOW_ALL = True
|
|
|
|
|
|
|
|
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',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
ROOT_URLCONF = 'YY_RMS_Multiple_Manage.urls'
|
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
'DIRS': [],
|
|
|
|
'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 = 'YY_RMS_Multiple_Manage.wsgi.application'
|
|
|
|
|
|
|
|
|
|
|
|
# Database
|
|
|
|
# https://docs.djangoproject.com/en/2.2/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.2/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.2/topics/i18n/
|
|
|
|
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
|
|
|
|
TIME_ZONE = 'Asia/Shanghai'
|
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
USE_L10N = True
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
|
|
|
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
|
|
|
|
|
|
|
|
# 程序运行时加载 只加载一次
|
|
|
|
GetDrugTypeData.init()
|
|
|
|
flag_ = True
|
|
|
|
|
|
|
|
# 日志管理器
|
|
|
|
# 给过滤器使用的判断
|
|
|
|
|
|
|
|
|
|
|
|
class RequireDebugTrue(logging.Filter):
|
|
|
|
# 实现filter方法
|
|
|
|
def filter(self, record):
|
|
|
|
return DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
log_file_path = os.path.join(BASE_DIR, 'runserver_log')
|
|
|
|
if not os.path.exists(log_file_path):
|
|
|
|
os.makedirs(log_file_path)
|
|
|
|
print("日志文件夹创建成功~~~~~~~~~~~~~~~~~~~")
|
|
|
|
|
|
|
|
|
|
|
|
LOGGING = {
|
|
|
|
# 基本设置
|
|
|
|
'version': 1, # 日志级别
|
|
|
|
'disable_existing_loggers': False, # 是否禁用现有的记录器
|
|
|
|
|
|
|
|
# 日志格式集合
|
|
|
|
'formatters': {
|
|
|
|
# 标准输出格式
|
|
|
|
'standard': {
|
|
|
|
# [具体时间][日志名字:日志级别名称(日志级别ID)] [输出的模块:输出的函数]:调用日志输出函数的语句所在的代码行-日志内容
|
|
|
|
'format': '具体时间:[%(asctime)s][%(name)s:%(levelname)s(%(lineno)d)]\n当前文件位置:[%(pathname)s]'
|
|
|
|
'模块名:[%(module)s:]函数名:[%(funcName)s]:\n[第%(lineno)d行]-%(message)s\n'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
# 过滤器
|
|
|
|
'filters': {
|
|
|
|
'require_debug_true': {
|
|
|
|
'()': RequireDebugTrue,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
# 处理器集合
|
|
|
|
'handlers': {
|
|
|
|
# 输出到控制台
|
|
|
|
'console': {
|
|
|
|
'level': 'DEBUG', # 输出信息的最低级别
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
'formatter': 'standard', # 使用standard格式
|
|
|
|
'filters': ['require_debug_true', ], # 仅当 DEBUG = True 该处理器才生效
|
|
|
|
},
|
|
|
|
# 输出到文件
|
|
|
|
'log': {
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'class': 'logging.handlers.RotatingFileHandler',
|
|
|
|
'formatter': 'standard',
|
|
|
|
# 输出位置
|
|
|
|
# 'filename': os.path.join(BASE_DIR, 'runserver_log/%s.log' % time.strftime('%Y_%m_%d')),
|
|
|
|
'filename': os.path.join(log_file_path, '%s.log' % time.strftime('%Y_%m_%d')),
|
|
|
|
'maxBytes': 1024*1024*5, # 文件大小 5M
|
|
|
|
'backupCount': 5, # 备份份数
|
|
|
|
'encoding': 'utf8', # 文件编码
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
# 日志管理器集合
|
|
|
|
'loggers': {
|
|
|
|
# 管理器
|
|
|
|
'default': {
|
|
|
|
'handlers': ['console', 'log'],
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'propagate': True, # 是否传递给父记录器
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|