""" Django settings for exam project. Generated by 'django-admin startproject' using Django 1.11.2. For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/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__))) WEB_DIR = os.path.join(BASE_DIR, 'web') # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'n@dmhs9)21$mzj7an@_89q_fusqws@p+qy(np0vmcdmgk7c$@i' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True TEMPLATE_DEBUG = True ALLOWED_HOSTS = ['http://127.0.0.1:8000/'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'account', 'business', 'competition', ] 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', 'utils.processors.UserAgentDetectionMiddleware', ] ROOT_URLCONF = 'config.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(WEB_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', ], 'loaders': [ ('django.template.loaders.cached.Loader', [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ]), ], }, }, ] WSGI_APPLICATION = 'config.wsgi.application' # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'exam', 'USER': 'root', 'PASSWORD': '' } } # Redis配置 REDIS = { 'default': { 'HOST': '127.0.0.1', 'PORT': 6379, 'USER': '', 'PASSWORD': '', 'db': 0, } } # Password validation # https://docs.djangoproject.com/en/1.11/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/1.11/topics/i18n/ LANGUAGE_CODE = 'zh-Hans' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = True SESSION_COOKIE_AGE = 60 * 60 * 24 # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(WEB_DIR, 'static'), ) STATIC_ROOT = os.path.join(BASE_DIR, 'collect_static') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') BANK_REPO = '/home/hugo/bank_backup' # Extension Configuration BASE_NUM_ID = 100000 INIT_PASSWORD = 'p@ssw0rd' DOMAIN = "http://127.0.0.1:8000" WEB_INDEX_URI = "{}/web/index".format(DOMAIN) WEB_LOGIN_REDIRECT_URI = "{}/auth/login_redirect" # send e-mail EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS = True EMAIL_USE_SSL = False EMAIL_SSL_CERTFILE = None EMAIL_SSL_KEYFILE = None EMAIL_TIMEOUT = None EMAIL_HOST = '' EMAIL_PORT = 465 EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = 'check from local_settings' # 错误信息邮件设置 # Email address that error messages come from. SERVER_EMAIL = EMAIL_HOST_USER # Default email address to use for various automated correspondence from # the site managers. DEFAULT_FROM_EMAIL = EMAIL_HOST_USER # People who get code error notifications. # In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')] ADMINS = [(),] # Not-necessarily-technical managers of the site. They get broken link # notifications and other various emails. MANAGERS = ADMINS WXWEB_LOGIN_PARAMS = { "appid": "xx", "token": "", "appsecret": "", "scope": "snsapi_login", "redirect_uri": WEB_INDEX_URI, "domain": DOMAIN, "state": "wxweblogin" } # logger 设置 LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'simple': { 'format': '%(levelname)s %(message)s' }, }, 'handlers': { 'email': { 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler', 'formatter':'verbose' }, 'file': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'filename': 'tmp/test.log', 'formatter': 'verbose', }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'verbose' }, }, 'loggers': { 'file': { 'handlers': ['file'], 'level': 'DEBUG', 'propagate': True, }, 'console': { 'handlers': ['console'], 'level': 'DEBUG', 'propagate': True, }, 'email': { 'handlers': ['email'], 'level': 'ERROR', 'propagate': True, } }, } # 引入外部settings文件 try: from config.local_settings import * except ImportError: pass