1. APIView使用介绍
-
介绍
之前我们写cbv是继承django.views的View
现在继承rest_framework.views的APIView
实际上APIView也是继承了Django的View
-
使用
1. 导入 from rest_framework.views import APIView 2. 视图(views)层 class Book(APIView): def get(self, request): pass def post(self, request): pass 3. 路由 url(r'^book/$', views.Book.as_view()),
2. APIView流程分析
写了好多发现说不清楚,上图吧