[Answered ]-Convert Queryset to dictionary with values for JSON

2👍

serializers.serialize is for full querysets only. But values returns a container of dicts, so you can more or less pass that directly to json.dumps – all you need to do is convert the container itself to a list.

lists = Actor.objects.actor_like(query)
data = json.dumps(list(lists))

Leave a comment