查询所有
作者:互联网
class BooksView(APIView): def get(self,request): response_msg = {'status': 100, 'msg': '成功'} books=Book.objects.all() book_ser=BookSerializer(books,many=True) #序列化多条,如果序列化一条,不需要写 response_msg['data']=book_ser.data return Response(response_msg) #urls.py path('books/', views.BooksView.as_view()),
标签:ser,所有,查询,BooksView,books,msg,序列化,response 来源: https://www.cnblogs.com/dzs894330350/p/16104765.html