From 963302d6f7225d45f1afcedb940ac361bdfee22e Mon Sep 17 00:00:00 2001 From: Daniel Amarillo Morales <32068902+damarillom@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:04:05 +0200 Subject: [PATCH] Update encoders.py --- rest_framework/utils/encoders.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py index aa4542286..07508fb69 100644 --- a/rest_framework/utils/encoders.py +++ b/rest_framework/utils/encoders.py @@ -41,8 +41,7 @@ class JSONEncoder(json.JSONEncoder): elif isinstance(obj, datetime.timedelta): return str(obj.total_seconds()) elif isinstance(obj, decimal.Decimal): - # Serializers will coerce decimals to strings by default. - return float(obj) + return str(obj) elif isinstance(obj, uuid.UUID): return str(obj) elif isinstance(obj, QuerySet):