Fixed #13107: Adjusted decimal_places validation to accept 0 as a valid value. Thanks to loewis for report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12774 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
794690c272
commit
c10b227b69
|
@ -45,18 +45,20 @@ def get_validation_errors(outfile, app=None):
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
e.add(opts, '"%s": CharFields require a "max_length" attribute that is a positive integer.' % f.name)
|
e.add(opts, '"%s": CharFields require a "max_length" attribute that is a positive integer.' % f.name)
|
||||||
if isinstance(f, models.DecimalField):
|
if isinstance(f, models.DecimalField):
|
||||||
|
decimalp_msg ='"%s": DecimalFields require a "decimal_places" attribute that is a non-negative integer.'
|
||||||
try:
|
try:
|
||||||
decimal_places = int(f.decimal_places)
|
decimal_places = int(f.decimal_places)
|
||||||
if decimal_places <= 0:
|
if decimal_places < 0:
|
||||||
e.add(opts, '"%s": DecimalFields require a "decimal_places" attribute that is a positive integer.' % f.name)
|
e.add(opts, decimalp_msg % f.name)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
e.add(opts, '"%s": DecimalFields require a "decimal_places" attribute that is a positive integer.' % f.name)
|
e.add(opts, decimalp_msg % f.name)
|
||||||
|
mdigits_msg = '"%s": DecimalFields require a "max_digits" attribute that is a positive integer.'
|
||||||
try:
|
try:
|
||||||
max_digits = int(f.max_digits)
|
max_digits = int(f.max_digits)
|
||||||
if max_digits <= 0:
|
if max_digits <= 0:
|
||||||
e.add(opts, '"%s": DecimalFields require a "max_digits" attribute that is a positive integer.' % f.name)
|
e.add(opts, mdigits_msg % f.name)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
e.add(opts, '"%s": DecimalFields require a "max_digits" attribute that is a positive integer.' % f.name)
|
e.add(opts, mdigits_msg % f.name)
|
||||||
if isinstance(f, models.FileField) and not f.upload_to:
|
if isinstance(f, models.FileField) and not f.upload_to:
|
||||||
e.add(opts, '"%s": FileFields require an "upload_to" attribute.' % f.name)
|
e.add(opts, '"%s": FileFields require an "upload_to" attribute.' % f.name)
|
||||||
if isinstance(f, models.ImageField):
|
if isinstance(f, models.ImageField):
|
||||||
|
|
|
@ -210,11 +210,11 @@ class UniqueFKTarget2(models.Model):
|
||||||
model_errors = """invalid_models.fielderrors: "charfield": CharFields require a "max_length" attribute that is a positive integer.
|
model_errors = """invalid_models.fielderrors: "charfield": CharFields require a "max_length" attribute that is a positive integer.
|
||||||
invalid_models.fielderrors: "charfield2": CharFields require a "max_length" attribute that is a positive integer.
|
invalid_models.fielderrors: "charfield2": CharFields require a "max_length" attribute that is a positive integer.
|
||||||
invalid_models.fielderrors: "charfield3": CharFields require a "max_length" attribute that is a positive integer.
|
invalid_models.fielderrors: "charfield3": CharFields require a "max_length" attribute that is a positive integer.
|
||||||
invalid_models.fielderrors: "decimalfield": DecimalFields require a "decimal_places" attribute that is a positive integer.
|
invalid_models.fielderrors: "decimalfield": DecimalFields require a "decimal_places" attribute that is a non-negative integer.
|
||||||
invalid_models.fielderrors: "decimalfield": DecimalFields require a "max_digits" attribute that is a positive integer.
|
invalid_models.fielderrors: "decimalfield": DecimalFields require a "max_digits" attribute that is a positive integer.
|
||||||
invalid_models.fielderrors: "decimalfield2": DecimalFields require a "decimal_places" attribute that is a positive integer.
|
invalid_models.fielderrors: "decimalfield2": DecimalFields require a "decimal_places" attribute that is a non-negative integer.
|
||||||
invalid_models.fielderrors: "decimalfield2": DecimalFields require a "max_digits" attribute that is a positive integer.
|
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 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: "decimalfield3": DecimalFields require a "max_digits" attribute that is a positive integer.
|
||||||
invalid_models.fielderrors: "filefield": FileFields require an "upload_to" 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: "choices": "choices" should be iterable (e.g., a tuple or list).
|
||||||
|
|
Loading…
Reference in New Issue