from django.http import HttpResponse
class MyException():
def process_exception(request,response, exception):
return HttpResponse(exception.message)
MIDDLEWARE_CLASSES = (
‘test1.myexception.MyException‘,
...
)
原文:https://www.cnblogs.com/alexzhang92/p/9529763.html