Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix #16570: Restore ability to have decimal fields where max_digits e…

…quals decimal_places. Thanks dcwatson and kenth.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17089 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit efe4e2e5178d2d6e6f710c3edee0d07cd6a60ab5 1 parent 63ba472
Karen Tracey authored November 12, 2011
2  AUTHORS
@@ -528,7 +528,7 @@ answer newbie questions, and generally made Django that much better:
528 528
     wam-djangobug@wamber.net
529 529
     Wang Chun <wangchun@exoweb.net>
530 530
     Filip Wasilewski <filip.wasilewski@gmail.com>
531  
-    Dan Watson <http://theidioteque.net/>
  531
+    Dan Watson <http://danwatson.net/>
532 532
     Joel Watts <joel@joelwatts.com>
533 533
     Lakin Wecker <lakin@structuredabstraction.com>
534 534
     Chris Wesseling <Chris.Wesseling@cwi.nl>
4  django/core/management/validation.py
@@ -72,9 +72,9 @@ def get_validation_errors(outfile, app=None):
72 72
                         mdigits_ok = True
73 73
                 except (ValueError, TypeError):
74 74
                     e.add(opts, mdigits_msg % f.name)
75  
-                invalid_values_msg = '"%s": DecimalFields require a "max_digits" attribute value that is greater than the value of the "decimal_places" attribute.'
  75
+                invalid_values_msg = '"%s": DecimalFields require a "max_digits" attribute value that is greater than or equal to the value of the "decimal_places" attribute.'
76 76
                 if decimalp_ok and mdigits_ok:
77  
-                    if decimal_places >= max_digits:
  77
+                    if decimal_places > max_digits:
78 78
                         e.add(opts, invalid_values_msg % f.name)
79 79
             if isinstance(f, models.FileField) and not f.upload_to:
80 80
                 e.add(opts, '"%s": FileFields require an "upload_to" attribute.' % f.name)
2  docs/ref/models/fields.txt
@@ -450,7 +450,7 @@ A fixed-precision decimal number, represented in Python by a
450 450
 .. attribute:: DecimalField.max_digits
451 451
 
452 452
     The maximum number of digits allowed in the number. Note that this number
453  
-    must be greater than ``decimal_places``, if it exists.
  453
+    must be greater than or equal to ``decimal_places``, if it exists.
454 454
 
455 455
 .. attribute:: DecimalField.decimal_places
456 456
 
3  tests/modeltests/invalid_models/invalid_models/models.py
@@ -243,8 +243,7 @@ class PrimaryKeyNull(models.Model):
243 243
 invalid_models.fielderrors: "decimalfield2": DecimalFields require a "max_digits" attribute that is a positive integer.
244 244
 invalid_models.fielderrors: "decimalfield3": DecimalFields require a "decimal_places" attribute that is a non-negative integer.
245 245
 invalid_models.fielderrors: "decimalfield3": DecimalFields require a "max_digits" attribute that is a positive integer.
246  
-invalid_models.fielderrors: "decimalfield4": DecimalFields require a "max_digits" attribute value that is greater than the value of the "decimal_places" attribute.
247  
-invalid_models.fielderrors: "decimalfield5": DecimalFields require a "max_digits" attribute value that is greater than the value of the "decimal_places" attribute.
  246
+invalid_models.fielderrors: "decimalfield4": DecimalFields require a "max_digits" attribute value that is greater than or equal to the value of the "decimal_places" attribute.
248 247
 invalid_models.fielderrors: "filefield": FileFields require an "upload_to" attribute.
249 248
 invalid_models.fielderrors: "choices": "choices" should be iterable (e.g., a tuple or list).
250 249
 invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-tuples.
5  tests/regressiontests/model_fields/models.py
@@ -69,6 +69,11 @@ class BooleanModel(models.Model):
69 69
 class RenamedField(models.Model):
70 70
     modelname = models.IntegerField(name="fieldname", choices=((1,'One'),))
71 71
 
  72
+# This model isn't used in any test, just here to ensure it validates successfully.
  73
+# See ticket #16570.
  74
+class DecimalLessThanOne(models.Model):
  75
+    d = models.DecimalField(max_digits=3, decimal_places=3)
  76
+
72 77
 ###############################################################################
73 78
 # FileField
74 79
 

0 notes on commit efe4e2e

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