Django的rest_framework的视图之Mixin类编写视图源码解析
Django的rest_framework的视图之Mixin类编写视图源码解析 Mixin类编写视图 我们这里用auther表来做演示,先为auther和autherdetail写2个url url(r'^autherdetail/(?P<id>\d+)', views.Book_detail_cbv.as_view(), name="autherdetail"), url(r'^auther/', views.Book_cbv.as_view(),name="auther"), 然后分别为这2个类写对应的序列化的类 class authermodelserializer(serializers.ModelSerializer): class Meta: model = models.Auther fields = "__all__" 下面我们开写视图函数 需要在view文件中导入2个模块 1 2 from rest_framework import mixins from rest_framework import generics 先介绍一下mixins类