2020
10-09
10-09
解决Django响应JsonResponse返回json格式数据报错问题
代码returnJsonResponse({"name":"tom"})报错:TYPEERROR:Inordertoallownon-dictobjectstobeserializedsetthesafeparmetertoFalse解决:returnJsonResponse({"name":"tom"},safe=False)增加safe=false,使其接受列表补充知识:python里面JsonResponse(book_list,safe=False)代码为:#查询所有图书、增加图书defget(self,request):queryset=BookInfo.objects.all()book_list=[]forbookinqu...
继续阅读 >