To suppress the administrator’s email, define a registration filter:
def skip_suspicious_operations(record): if record.name == 'django.security.DisallowedHost': return False return True
Then in settings.py add it to the LOGGING dict as a filter:
'filters': { 'skip_suspicious_operations': { '()': 'django.utils.log.CallbackFilter', 'callback': skip_suspicious_operations, } }
and add a filter to the mail_admins handler:
'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['skip_suspicious_operations'], 'include_html' : True, } }
This works in Django 1.6 as it is. In Django-1.5, I think the RHS comparison with record.name is a bit different, but it should work otherwise.
Nils Jan 16 '14 at 18:54 2014-01-16 18:54
source share