diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 5e3509857b1..e254ef4ad55 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -620,7 +620,8 @@ class DecimalField(Field): try: return decimal.Decimal(value) except decimal.InvalidOperation: - raise validators.ValidationError, ugettext("This value must be a decimal number.") + raise validators.ValidationError( + _("This value must be a decimal number.")) def _format(self, value): if isinstance(value, basestring): diff --git a/tests/regressiontests/model_fields/__init__.py b/tests/regressiontests/model_fields/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/regressiontests/model_fields/models.py b/tests/regressiontests/model_fields/models.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py new file mode 100644 index 00000000000..e279a0669fc --- /dev/null +++ b/tests/regressiontests/model_fields/tests.py @@ -0,0 +1,18 @@ +""" +>>> from django.db.models.fields import * + +# DecimalField + +>>> f = DecimalField() + +>>> f.to_python(3) +Decimal("3") + +>>> f.to_python("3.14") +Decimal("3.14") + +>>> f.to_python("abc") +Traceback (most recent call last): +... +ValidationError: [u'This value must be a decimal number.'] +"""