Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed call to `ugettext`, which is imported as `_`.

Changed raise to conform to PEP 3109 and wrapped the long line.
Added beginnings of tests for model fields.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5778 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f27774ee0ab4b2537909d642c23ea6ae6ea8d166 1 parent d76e532
Gary Wilson Jr. authored July 30, 2007
3  django/db/models/fields/__init__.py
@@ -620,7 +620,8 @@ def to_python(self, value):
620 620
         try:
621 621
             return decimal.Decimal(value)
622 622
         except decimal.InvalidOperation:
623  
-            raise validators.ValidationError, ugettext("This value must be a decimal number.")
  623
+            raise validators.ValidationError(
  624
+                _("This value must be a decimal number."))
624 625
 
625 626
     def _format(self, value):
626 627
         if isinstance(value, basestring):
0  tests/regressiontests/model_fields/__init__.py
No changes.
0  tests/regressiontests/model_fields/models.py
No changes.
18  tests/regressiontests/model_fields/tests.py
... ...
@@ -0,0 +1,18 @@
  1
+"""
  2
+>>> from django.db.models.fields import *
  3
+
  4
+# DecimalField
  5
+
  6
+>>> f = DecimalField()
  7
+
  8
+>>> f.to_python(3)
  9
+Decimal("3")
  10
+
  11
+>>> f.to_python("3.14")
  12
+Decimal("3.14")
  13
+
  14
+>>> f.to_python("abc")
  15
+Traceback (most recent call last):
  16
+...
  17
+ValidationError: [u'This value must be a decimal number.']
  18
+"""

0 notes on commit f27774e

Please sign in to comment.
Something went wrong with that request. Please try again.