0
我有查询集:
queryset = Status.objects.all()[:10]
型号Status
没有得到现场commentAmount
所以我把它添加到每一个对象在查询集:
使用新动态创建的字段更新模型对象?
for s in queryset:
s.commentAmount = s.getCommentAmount()
一切都很好,print s.commentAmount
显示效果不错,但后:
response = HttpResponse()
response['Content-Type'] = "text/javascript"
response.write(serializers.serialize("json", queryset))
return response
我没有字段commentAmount
在返回JSON文件。我的错误在哪里?