Skip to content Skip to sidebar Skip to footer

Serialize Django Model Queryset With Serializers.serialize() Function

How can I return JSON response of model queryset from a view using django serializer ? from django.core import serializers from django.http.response import JsonResponse def some_

Solution 1:

This can be easily done by using python format.

serialized_obj = serializers.serialize('python', qs)

Unfortunately, Django serializer doc doesn't mention anything about it, but the source code does

Post a Comment for "Serialize Django Model Queryset With Serializers.serialize() Function"