[Fixed]-How serialize count() from sql query to JSON

1👍

You don’t have a proper queryset, so there isn’t much point in using the built-in serializers. Just create a list of dicts, and use JsonResponse to return it as JSON.

data = [{'id': o.id, 'identification': o.identification, 'total': o.total} for o in observations]
return JsonResponse(data)

Leave a comment