您当前的位置: 首页 >  彭世瑜 json

Django响应JsonResponse返回json格式数据报错

彭世瑜 发布时间:2018-09-18 14:25:09 ,浏览量:3

代码

return JsonResponse({"name": "tom"})

报错:

TYPEERROR: In order to allow non-dict objects to be serialized 
set the safe parmeter to False 

解决:

return JsonResponse({"name": "tom"},  safe=False)

增加safe=false,使其接受列表

参考: Django开发过程中的一些bug及解决方法

关注
打赏
1688896170
查看更多评论

彭世瑜

暂无认证

  • 3浏览

    0关注

    2727博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0814s