from sys import exc_info from django views debug import technical_404_

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from sys import exc_info
from django.views.debug import technical_404_response, technical_500_response
from django import Http404, Http500
class TechnicalExceptionMiddleware:
def process_exception(self, request, exception):
if request.user.is_superuser:
if isinstance(exception, Http404):
return technical_404_response(request, *exc_info())
else:
return technical_500_response(request, *exc_info())