Since the process_exception middleware receives the request object, you can add any information you want to request. META
class ErrorMiddleware(object):
"""
Alter HttpRequest objects on Error
"""
def process_exception(self, request, exception):
"""
Add user details.
"""
request.META['USER'] = request.user.username
source
share