Integrate better-exceptions with Django
masterTo use better_exceptions in Django, add better_exceptions.integrations.django.BetterExceptionsMiddleware to your MIDDLEWARE setting. To prevent duplicate logs (one from better_exceptions and one from Django), configure your LOGGING dictionary to use the skip_errors_filter from better_exceptions.integrations.django.
# settings.py
MIDDLEWARE = [
# ...
"better_exceptions.integrations.django.BetterExceptionsMiddleware",
]
# ...
from better_exceptions.integrations.django import skip_errors_filter
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'skip_errors': {
'()': 'django.utils.log.CallbackFilter',
'callback': skip_errors_filter,
}
},
'handlers': {
'console': {
'level': 'INFO',
'filters': ['skip_errors'],
'class': 'logging.StreamHandler',
}
},
'loggers': {
'django': {
'handlers': [
'console',
],
}
}
}