'Validate that the input is a decimal number and return a Decimal
instance.'

def to_internal_value(self, data):

    data = smart_text(data).strip()
    if self.localize:
        data = sanitize_separators(data)
    if (len(data) > self.MAX_STRING_LENGTH):
        self.fail(u'max_string_length')
    try:
        value = decimal.Decimal(data)
    except decimal.DecimalException:
        self.fail(u'invalid')
    if (value != value):
        self.fail(u'invalid')
    if (value in (decimal.Decimal(u'Inf'), decimal.Decimal(u'-Inf'))):
        self.fail(u'invalid')
    return self.quantize(self.validate_precision(value))
