diff options
| author | Karen Tracey <kmtracey@gmail.com> | 2010-03-13 22:15:09 +0000 |
|---|---|---|
| committer | Karen Tracey <kmtracey@gmail.com> | 2010-03-13 22:15:09 +0000 |
| commit | c94de0757097061753578c72fb2abc8a5c603531 (patch) | |
| tree | b199b41d70eac96d761ac35500214dc50c8bdd40 /django/core | |
| parent | e969c2715f5b3a7b7d66dcae5a0482de38f47106 (diff) | |
[1.1.X] Fixed #13107: Adjusted decimal_places validation to accept 0 as a valid value. Thanks to loewis for report.
r12774 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12775 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/management/validation.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/django/core/management/validation.py b/django/core/management/validation.py index 06b891b32a..0e6d8b200f 100644 --- a/django/core/management/validation.py +++ b/django/core/management/validation.py @@ -45,18 +45,20 @@ def get_validation_errors(outfile, app=None): except (ValueError, TypeError): e.add(opts, '"%s": CharFields require a "max_length" attribute that is a positive integer.' % f.name) if isinstance(f, models.DecimalField): + decimalp_msg ='"%s": DecimalFields require a "decimal_places" attribute that is a non-negative integer.' try: decimal_places = int(f.decimal_places) - if decimal_places <= 0: - e.add(opts, '"%s": DecimalFields require a "decimal_places" attribute that is a positive integer.' % f.name) + if decimal_places < 0: + e.add(opts, decimalp_msg % f.name) 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: max_digits = int(f.max_digits) 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): - 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: e.add(opts, '"%s": FileFields require an "upload_to" attribute.' % f.name) if isinstance(f, models.ImageField): |
