当设置DEBUG = False时,我在使用Django 1.10时遇到了一个非常奇怪的行为。 Django日志记录实用程序陷入无限循环,并向我发送大量电子邮件,而不是仅向我发送一封电子邮件。实际上,在我停止Apache之前它不会停止。
我尝试降级到Django 1.9并且它解决了问题。
我还尝试在settings.py中明确设置AdminEmailHandler,以便在DEBUG = True且解决问题时启用电子邮件日志记录。
我正在使用Apache + mod_wsgi。
这是我的(非常基本的)settings.py:
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = "0m(!5fot^1kw)gs=rw%0)assk+y=s$)8y!g)l2b2i2@&#%kn25"
DEBUG = False
ALLOWED_HOSTS = ['127.0.0.1','172.18.0.2']
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',]
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 = 'hydra.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 = 'hydra.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'hydra_db',
'USER': 'juju',
'PASSWORD': 'pass',
'HOST': '172.18.0.1'
},
}
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',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
ADMINS = (
('Juju', 'toto@gmail.com'),
)
MANAGERS = ADMINS
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'toto@gmail.com'
EMAIL_HOST_PASSWORD = 'pass'
EMAIL_USE_TLS = True
总而言之,它似乎与Django 1.10和DEBUG = False模式相关联。 你知道造成这种情况的原因吗?
提前感谢您的帮助!