Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@kmtracey kmtracey authored
View
2  AUTHORS
@@ -528,7 +528,7 @@ answer newbie questions, and generally made Django that much better:
wam-djangobug@wamber.net
Wang Chun <wangchun@exoweb.net>
Filip Wasilewski <filip.wasilewski@gmail.com>
- Dan Watson <http://theidioteque.net/>
+ Dan Watson <http://danwatson.net/>
Joel Watts <joel@joelwatts.com>
Lakin Wecker <lakin@structuredabstraction.com>
Chris Wesseling <Chris.Wesseling@cwi.nl>
View
4 django/core/management/validation.py
@@ -72,9 +72,9 @@ def get_validation_errors(outfile, app=None):
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)
View
2  docs/ref/models/fields.txt
@@ -450,7 +450,7 @@ A fixed-precision decimal number, represented in Python by a
.. 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
View
3  tests/modeltests/invalid_models/invalid_models/models.py
@@ -243,8 +243,7 @@ class PrimaryKeyNull(models.Model):
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.
View
5 tests/regressiontests/model_fields/models.py
@@ -69,6 +69,11 @@ class BooleanModel(models.Model):
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
Please sign in to comment.
Something went wrong with that request. Please try again.