异常模块源码入口 APIView类中dispatch方法中的:response = self.handle_exception(exc) 源码分析 我们点击handle_exception跳转,查看该方法源码 def handle_exception(self, exc): """ Handle any exception that occurs, by returning an appropriate response, or re-raising the error. &…
基本代码结构 url.py: from django.conf.urls import url, include from app import views urlpatterns = [ url(r'^test/', views.TestView.as_view()), ] views.py: from rest_framework.views import APIView from rest_framework.response import Response from rest_frame…