此处只是做个记录,不适合深入,纯属复制粘贴
https://blog.csdn.net/qq_39147299/article/details/108772941
https://www.cnblogs.com/noteaddr/p/12937093.html
from rest_framework.views import exception_handler from rest_framework.response import Response def my_exception_handler(exc, context): response = exception_handler(exc, context) if not response: response = Response({'detail': '服务器异常,%s' % exc},status=500) return response setting.py 'EXCEPTION_HANDLER': 'utils.custom_exception.my_exception_handler',