2👍
✅
values()
returns a ValuesQuerySet
which is not directly serializable via json.dumps()
.
Convert it to list
before dumping:
values = objectList.values('id', 'name', 'geom_type')
data = list(values) # becomes list of dictionaries
jsonData = json.dumps(data)
Source:stackexchange.com