2

I am facing a very strange behavior with Django 1.10 when setting DEBUG=False. Django logging utility is stuck in an infinite loop and is sending me tons of emails instead of only sending me one email. Actually it doesn't stop until I am stopping Apache.

I tried downgrading to Django 1.9 and it solves the issue.

I also tried explicitly setting an AdminEmailHandler in settings.py in order to enable email logging when DEBUG=True and it solves the issue.

I am using Apache + mod_wsgi.

Here is my (pretty basic) 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

To sum up, it seems linked to Django 1.10 and DEBUG=False mode. Do you know what can be causing this ?

Thanks in advance for your help !

Julien Salinas
  • 1,059
  • 1
  • 10
  • 23

0 Answers0