【发布时间】:2015-04-28 16:55:32
【问题描述】:
我正在尝试在 django 中创建一个 json 数组,但出现错误 -
In order to allow non-dict objects to be serialized set the safe parameter to False
还有我的views.py -
def wall_copy(request):
if True:
posts = user_post.objects.order_by('id')[:20].reverse()
return JsonResponse(posts)
基本上 user_post 是一个模型,posts 是前 20 个保存数据的对象。我想发送一个 json 数组,但我无法将帖子转换为 json 数组。我也尝试了序列化程序,但没有帮助。
我卡住了,请帮帮我。
提前致谢。
【问题讨论】: