from django.db import DatabaseError


class DatabaseErrorMiddleware(object):

    def process_view(self, request, view, args, kwargs):
        pass
Django - How to get debug info of DatabaseError "current transaction is aborted" in Django error page?