File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 105105LOGGING = DEFAULT_LOGGING .copy ()
106106LOGGING ['handlers' ]['mail_admins' ]['include_html' ] = True
107107
108+ # Filter out "Invalid HTTP_HOST" emails
109+ # Based on http://www.tiwoc.de/blog/2013/03/django-prevent-email-notification-on-suspiciousoperation/
110+ from django .core .exceptions import SuspiciousOperation
111+ def skip_suspicious_operations (record ):
112+ if record .exc_info :
113+ exc_value = record .exc_info [1 ]
114+ if isinstance (exc_value , SuspiciousOperation ):
115+ return False
116+ return True
117+ LOGGING ['filters' ]['skip_suspicious_operations' ] = {
118+ '()' : 'django.utils.log.CallbackFilter' ,
119+ 'callback' : skip_suspicious_operations ,
120+ }
121+ LOGGING ['handlers' ]['mail_admins' ]['filters' ] += [ 'skip_suspicious_operations' ]
122+
108123SESSION_COOKIE_AGE = 43200 # 12 hours
109124SESSION_EXPIRE_AT_BROWSER_CLOSE = True
110125SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
You can’t perform that action at this time.
0 commit comments