【发布时间】:2015-02-07 14:52:27
【问题描述】:
我想知道为什么从查询集中检索到的这些数据不能用 JSON 序列化?
objectList = Layers.objects.all()
data = [objectList.values('id', 'name', 'geom_type')]
jsonData = json.dumps(data)
>>> [{'id': 7, 'geom_type': u'Polygon', 'name': u'ra_general'}, {'id': 6, 'geom_type': u'Polygon', 'name': u'square'}] is not JSON serializable
实现这一目标的正确方法是什么?
【问题讨论】:
标签: python json django django-models django-queryset