ModelViewSet的使用
1.models
from rest_framework.viewsets import ModelViewSet class publish(ModelViewSet): queryset = models.Book.objects.all() serializer_class =Myserializations.BookModelSerializers
2.路由的设置
url(r'^publish/', views.publish.as_view({'get':'list','post':'create'})), url(r'^publishs/(?P<pk>\d+)', views.publish.as_view({'get':'retrieve','put':'update','delete':'destroy'})),