123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- """
- Django settings for azoauth project.
- Generated by 'django-admin startproject' using Django 2.1.4.
- 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 = 'p7!s!=fn!a^e_&r46)*8*4y-bdyam$m@kr31e!+r56dtv##bz1'
- # 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',
- 'model'
- ]
- 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',
- 'django.middleware.common.CommonMiddleware',
- ]
- ROOT_URLCONF = 'azoauth.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 = 'azoauth.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'),
- }
- }
- # DATABASE_DATA = 'alexa_oauth'
- # SERVER_HOST = 'azrdsinstance.clraczw4p0yj.us-west-1.rds.amazonaws.com'
- # DATABASES_USER = 'azrds'
- # DATABASES_PASS = 'azrds.x.x'
- #
- # DATABASES = {'default': {
- # 'ENGINE': 'django.db.backends.mysql',
- # 'NAME': DATABASE_DATA,
- # 'USER': DATABASES_USER,
- # 'PASSWORD': DATABASES_PASS,
- # 'HOST': SERVER_HOST,
- # 'PORT': '3306',
- # 'OPTIONS': {'charset': 'utf8mb4', 'use_unicode': True, 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
- # 'AUTOCOMMIT': True
- # }}
- # 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 = '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.1/howto/static-files/
- STATIC_URL = '/static/'
- # 跨域增加忽略
- CORS_ALLOW_CREDENTIALS = True
- CORS_ORIGIN_ALLOW_ALL = True
- CORS_ORIGIN_WHITELIST = ()
- CORS_ALLOW_METHODS = (
- 'DELETE',
- 'GET',
- 'OPTIONS',
- 'PATCH',
- 'POST',
- 'PUT',
- 'VIEW',
- )
- CORS_ALLOW_HEADERS = (
- 'accept',
- 'accept-encoding',
- 'authorization',
- 'content-type',
- 'dnt',
- 'origin',
- 'user-agent',
- 'x-csrftoken',
- 'x-requested-with',
- )
- LOGGING = {
- 'version': 1,
- 'disable_existing_loggers': False if DEBUG else True, # 是否禁用已经存在的日志器
- 'formatters': { # 日志信息显示的格式
- 'verbose': {
- 'format': '%(levelname)s %(asctime)s %(module)s %(lineno)s %(message)s'
- # "class": "pythonjsonlogger.jsonlogger.JsonFormatter"
- },
- 'simple': {
- 'format': '%(levelname)s %(asctime)s %(module)s %(funcName)s %(lineno)d %(message)s'
- # "class": "pythonjsonlogger.jsonlogger.JsonFormatter"
- }, # 日志记录级别+时间日期+模块名称+函数名称+行号+记录消息
- },
- 'filters': { # 对日志进行过滤
- 'require_debug_true': { # django在debug模式下才输出日志
- '()': 'django.utils.log.RequireDebugTrue',
- },
- },
- 'handlers': { # 日志处理方法
- 'console': { # 向终端中输出日志
- 'level': 'DEBUG' if DEBUG else 'INFO',
- 'filters': ['require_debug_true'], # debug为true才会输出
- 'class': 'logging.StreamHandler',
- 'formatter': 'verbose'
- },
- 'info': { # 向文件中输出日志
- 'level': 'INFO',
- 'class': 'logging.handlers.RotatingFileHandler',
- 'filename': os.path.join(BASE_DIR+'/logs/', "info.log"), # 日志文件的位置
- 'maxBytes': 300 * 1024 * 1024, # 300M大小
- 'backupCount': 10,
- 'formatter': 'verbose',
- 'encoding': 'utf-8'
- },
- },
- 'loggers': { # 日志器
- "django": { # 默认的logger应用如下配置
- "handlers": ["info", "console"],
- "propagate": True,
- "level": "INFO"
- },
- }
- }
|