Admin Error Email Truncation using ExceptionReporter

Hello,
I have set up email error reporting in our Django application but we are finding the error email to be too verbose for our liking.
I have created a custom ExceptionReporter by extending the class, and have mostly achieved what we want, but I am now receiving two emails and would like guidance on a possibly more elegant solution.
I’ll paste the code below, as well as the two email contents.

class LessVerboseExceptionReporter(ExceptionReporter):
    def get_traceback_data(self):
        data = super().get_traceback_data()
        reduced_report = {
            "exception_value": data["exception_value"],
            "is_email": data["is_email"],
            "lastframe": data["lastframe"],
            "frames": data["frames"],
            "unicode_hint": data["unicode_hint"],
        }
        return reduced_report
import logging.config

LOGGING_CONFIG = None

LOGGING = {
   'version': 1,
   'disable_existing_loggers': False,
   'formatters': {
       'verbose': {
           'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
       },
   },
   'handlers': {
       'console': {
           'level': 'INFO',
           'class': 'logging.StreamHandler',
           'stream': sys.stdout,
           'formatter': 'verbose'  
       },
       'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
            'include_html': False, 
            'reporter_class': 'report.email.LessVerboseExceptionReporter'
        },
   },
   'loggers': {
       '': {
           'handlers': ['console', 'mail_admins'],
           'level': 'INFO',
           'propagate': True,
       },
   },
}
logging.config.dictConfig(LOGGING)

Email 1 (Desirable):

Internal Server Error: /dept_awarding/update_batch_status/

Report
'str' object has no attribute 'status'

Django Version:
Python Executable:
Python Version:
Python Path:
Server time:
Installed Applications:
''
Installed Middleware:
''


Traceback (most recent call last):
  File "C:\wamp64\www\apiano\win_env\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\wamp64\www\apiano\win_env\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\wamp64\www\apiano\win_env\Lib\site-packages\django\views\decorators\csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\wamp64\www\apiano\win_env\Lib\site-packages\django\views\generic\base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\wamp64\www\apiano\win_env\Lib\site-packages\rest_framework\views.py", line 509, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\wamp64\www\apiano\win_env\Lib\site-packages\rest_framework\views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\wamp64\www\apiano\win_env\Lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception
    raise exc
    ^^^^^^^^^
  File "C:\wamp64\www\apiano\win_env\Lib\site-packages\rest_framework\views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\wamp64\www\apiano\apiano_project\dept_awarding\views.py", line 133, in post
    row_status.status.status
    ^^^^^^^^^^^^^^^^^



Request data not supplied

Settings:
Using settings module

Email 2 (Undesirable):


​
"POST /foo/update_bar_status/ HTTP/1.1" 500 145

Report
"POST /foo/update_bar_status/ HTTP/1.1" 500 145

Django Version:
Python Executable:
Python Version:
Python Path:
Server time:
Installed Applications:
''
Installed Middleware:
''


Traceback (most recent call last):
  None

I’m curious - that second block of code you have posted here containing the logging configuration, what file do you have that in?

If it’s in your settings file, you don’t need to redefine the logging configurer. I would start with the hunch that it’s the “dual definition” of loggers that may be causing an issue here.

Django applies its default configuration first, then processes the settings file to override those defaults. (See Default settings)

Yep, that appears to be the issue. I thought at first that I was receiving two emails (the desireable one and then the default one) which caused me to do that configuration reset based on this python - Django mail_admins sending from multiple email backends - Stack Overflow. However, I am now just receiving the email that I want. Thanks!