Author: kmtracey
Date: 2011-11-12 11:53:56 -0800 (Sat, 12 Nov 2011)
New Revision: 17089
Modified:
django/trunk/AUTHORS
django/trunk/django/core/management/validation.py
django/trunk/docs/ref/models/fields.txt
django/trunk/tests/modeltests/invalid_models/invalid_models/models.py
django/trunk/tests/regressiontests/model_fields/models.py
Log:
Fix #16570: Restore ability to have decimal fields where max_digits equals
decimal_places. Thanks dcwatson and kenth.
Modified: django/trunk/AUTHORS
===================================================================
--- django/trunk/AUTHORS 2011-11-12 19:06:39 UTC (rev 17088)
+++ django/trunk/AUTHORS 2011-11-12 19:53:56 UTC (rev 17089)
@@ -528,7 +528,7 @@
[email protected]
Wang Chun <[email protected]>
Filip Wasilewski <[email protected]>
- Dan Watson <http://theidioteque.net/>
+ Dan Watson <http://danwatson.net/>
Joel Watts <[email protected]>
Lakin Wecker <[email protected]>
Chris Wesseling <[email protected]>
Modified: django/trunk/django/core/management/validation.py
===================================================================
--- django/trunk/django/core/management/validation.py 2011-11-12 19:06:39 UTC
(rev 17088)
+++ django/trunk/django/core/management/validation.py 2011-11-12 19:53:56 UTC
(rev 17089)
@@ -72,9 +72,9 @@
mdigits_ok = True
except (ValueError, TypeError):
e.add(opts, mdigits_msg % f.name)
- invalid_values_msg = '"%s": DecimalFields require a
"max_digits" attribute value that is greater than the value of the
"decimal_places" attribute.'
+ 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.'
if decimalp_ok and mdigits_ok:
- if decimal_places >= max_digits:
+ if decimal_places > max_digits:
e.add(opts, invalid_values_msg % f.name)
if isinstance(f, models.FileField) and not f.upload_to:
e.add(opts, '"%s": FileFields require an "upload_to"
attribute.' % f.name)
Modified: django/trunk/docs/ref/models/fields.txt
===================================================================
--- django/trunk/docs/ref/models/fields.txt 2011-11-12 19:06:39 UTC (rev
17088)
+++ django/trunk/docs/ref/models/fields.txt 2011-11-12 19:53:56 UTC (rev
17089)
@@ -450,7 +450,7 @@
.. attribute:: DecimalField.max_digits
The maximum number of digits allowed in the number. Note that this number
- must be greater than ``decimal_places``, if it exists.
+ must be greater than or equal to ``decimal_places``, if it exists.
.. attribute:: DecimalField.decimal_places
Modified: django/trunk/tests/modeltests/invalid_models/invalid_models/models.py
===================================================================
--- django/trunk/tests/modeltests/invalid_models/invalid_models/models.py
2011-11-12 19:06:39 UTC (rev 17088)
+++ django/trunk/tests/modeltests/invalid_models/invalid_models/models.py
2011-11-12 19:53:56 UTC (rev 17089)
@@ -243,8 +243,7 @@
invalid_models.fielderrors: "decimalfield2": DecimalFields require a
"max_digits" attribute that is a positive integer.
invalid_models.fielderrors: "decimalfield3": DecimalFields require a
"decimal_places" attribute that is a non-negative integer.
invalid_models.fielderrors: "decimalfield3": DecimalFields require a
"max_digits" attribute that is a positive integer.
-invalid_models.fielderrors: "decimalfield4": DecimalFields require a
"max_digits" attribute value that is greater than the value of the
"decimal_places" attribute.
-invalid_models.fielderrors: "decimalfield5": DecimalFields require a
"max_digits" attribute value that is greater than the value of the
"decimal_places" attribute.
+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.
invalid_models.fielderrors: "filefield": FileFields require an "upload_to"
attribute.
invalid_models.fielderrors: "choices": "choices" should be iterable (e.g., a
tuple or list).
invalid_models.fielderrors: "choices2": "choices" should be a sequence of
two-tuples.
Modified: django/trunk/tests/regressiontests/model_fields/models.py
===================================================================
--- django/trunk/tests/regressiontests/model_fields/models.py 2011-11-12
19:06:39 UTC (rev 17088)
+++ django/trunk/tests/regressiontests/model_fields/models.py 2011-11-12
19:53:56 UTC (rev 17089)
@@ -69,6 +69,11 @@
class RenamedField(models.Model):
modelname = models.IntegerField(name="fieldname", choices=((1,'One'),))
+# This model isn't used in any test, just here to ensure it validates
successfully.
+# See ticket #16570.
+class DecimalLessThanOne(models.Model):
+ d = models.DecimalField(max_digits=3, decimal_places=3)
+
###############################################################################
# FileField
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.