1.基于GenericAPIView下的9个视图子类功能关系梳理
from rest_framework.generics import CreateAPIView, ListAPIView, UpdateAPIView, RetrieveAPIView, DestroyAPIView, ListCreateAPIView,
RetrieveUpdateDestroyAPIView, RetrieveDestroyAPIView, RetrieveUpdateAPIView
CreateAPIView:
新增功能
源码分析:
ListAPIView:
查询所有功能
源码分析:
UpdateAPIView:
修改功能
源码分析:
RetrieveAPIView:
获取单条信息功能
源码分析:
DestroyAPIView:
删除功能
源码分析:
ListCreateAPIView:
上面的继承两个ListAPIView, CreateAPIView等同于继承一个ListCreateAPIView
源码分析:
RetrieveUpdateDestroyAPIView:
上面的继承三个UpdateAPIView, RetrieveAPIView, DestroyAPIView等同于继承一个RetrieveUpdateDestroyAPIView
源码分析:
RetrieveDestroyAPIView:
上面的继承两个DestroyAPIView,RetrieveAPIView等同于继承一个RetrieveDestroyAPIView
源码分析:
RetrieveUpdateAPIView:
上面的继承两个RetrieveAPIView,UpdateAPIView等同于继承一个RetrieveUpdateAPIView
源码分析:
1.GenericAPIView的5个扩展类写接口:
2.ListAPIView和CreateAPIView使用:
2_1.ListAPIView_查询所有响应:
2_2.CreateAPIView_新增一条:
3.修改功能(继承UpdateAPIView), 获取单条信息(继承RetrieveAPIView), 删除功能(继承DestroyAPIView):
3_1.获取单条信息(继承RetrieveAPIView)响应:
3_2.删除功能(继承DestroyAPIView)响应:
3_3.修改功能(继承UpdateAPIView)响应:
4.继承RetrieveUpdateDestroyAPIView:
5.9个视图子类总结: