          # Check for infinity and negative infinity.
          if value in (decimal.Decimal('Inf'), decimal.Decimal('-Inf')):
              self.fail('invalid')
  
          sign, digittuple, exponent = value.as_tuple()
          decimals = abs(exponent)
          # digittuple doesn't include any leading zeros.
          digits = len(digittuple)
          if decimals > digits:
 
</s> remove         context = decimal.getcontext().copy()
        context.prec = self.max_digits
        quantized = value.quantize(
            decimal.Decimal('.1') ** self.decimal_places,
            context=context
        )
 </s> add         quantized = self.quantize(value)
 </s> remove         Validates that the input is a decimal number. Returns a Decimal
        instance. Returns None for empty values. Ensures that there are no more
        than max_digits in the number, and no more than decimal_places digits
        after the decimal point.
 </s> add         Validate that the input is a decimal number and return a Decimal
        instance.
        return self.validate_precision(value)

    def validate_precision(self, value):
        """
        Ensure that there are no more than max_digits in the number, and no
        more than decimal_places digits after the decimal point.

        Override this method to disable the precision validation for input
        values or to enhance it in any way you need to.
        """
          # Check for infinity and negative infinity.
          if value in (decimal.Decimal('Inf'), decimal.Decimal('-Inf')):
              self.fail('invalid')
  
        return self.validate_precision(value)

    def validate_precision(self, value):
        """
        Ensure that there are no more than max_digits in the number, and no
        more than decimal_places digits after the decimal point.

        Override this method to disable the precision validation for input
        values or to enhance it in any way you need to.
        """
          sign, digittuple, exponent = value.as_tuple()
          decimals = abs(exponent)
          # digittuple doesn't include any leading zeros.
          digits = len(digittuple)
          if decimals > digits:
keep keep keep add keep keep keep keep keep
 Refactored DecimalField to allow easier subclassing 
rest_framework/fields.py