Out of range float values are not JSON compliant: nan, Django Rest Framework with Json Serialization Exception

Viewed 159

I work with rest_framework to implement a django API. The table Order from my database has nan fields, and Nan generates the error Out of range float values are not JSON compliant: nan. How to ensure that serializing Nan to JSON works.

#serializers.py

from rest_framework import serializers
from api.models import Order
    
class OrderSerializer(serializers.ModelSerializer):
   class Meta:
       model = Order
       fields = ('id', 'status', 'description')

The serialization here is a black box, i don't find where to fix this.

screenshot of error

0 Answers
Related