Suppress Django error reporting email

In Django, by default, when an exception raises, and is not handled, Django will send an email to people listed in ADMINS, reporting the error. But in many setup, we already have other mechanism to track those errors (like throwing to Sentry), so those emails will become annoying. How to stop Django from sending those emails.

We can do it by overriding mail_admins log handler, to use logging.NullHandler as handler class, like this:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'logging.NullHandler',
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': False,
        },
    },
}