Reputation: 7635
I would like to know why this data retrieved from queryset cannot be serialized in 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
what is the proper way to achieve that?
Upvotes: 1
Views: 264