diff --git a/rest_framework/fields.py b/rest_framework/fields.py index d5071a1aa..92caa6a38 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -1135,6 +1135,7 @@ class DecimalField(Field): return value context = decimal.getcontext().copy() + # For Python 2.7 compatibility when using cdecimal rounding = context.rounding if self.rounding is None else self.rounding if self.max_digits is not None: context.prec = self.max_digits