diff --git django/core/management/validation.py django/core/management/validation.py
index bb4fa55..83013a4 100644
|
|
|
1 | 1 | import sys |
| 2 | from decimal import Decimal |
2 | 3 | |
3 | 4 | from django.contrib.contenttypes.generic import GenericForeignKey, GenericRelation |
4 | 5 | from django.core.management.color import color_style |
… |
… |
def get_validation_errors(outfile, app=None):
|
68 | 69 | except (ValueError, TypeError): |
69 | 70 | e.add(opts, mdigits_msg % f.name) |
70 | 71 | invalid_values_msg = '"%s": DecimalFields require a "max_digits" attribute value that is greater than the value of the "decimal_places" attribute.' |
| 72 | default_type_msg ='"%s": DecimalFields require a "default" attribute that is of type Decimal.' |
| 73 | if f.has_default(): |
| 74 | try: |
| 75 | Decimal(f.default) |
| 76 | except (ValueError, TypeError): |
| 77 | e.add(opts, default_type_msg % f.name) |
71 | 78 | if decimalp_ok and mdigits_ok: |
72 | 79 | if decimal_places >= max_digits: |
73 | 80 | e.add(opts, invalid_values_msg % f.name) |
diff --git tests/modeltests/invalid_models/models.py tests/modeltests/invalid_models/models.py
index ab9edd6..3d81c3f 100644
|
|
class FieldErrors(models.Model):
|
16 | 16 | decimalfield3 = models.DecimalField(max_digits="bad", decimal_places="bad") |
17 | 17 | decimalfield4 = models.DecimalField(max_digits=9, decimal_places=10) |
18 | 18 | decimalfield5 = models.DecimalField(max_digits=10, decimal_places=10) |
| 19 | decimalfield6 = models.DecimalField(max_digits=10, decimal_places=2, default = 2.34) |
19 | 20 | filefield = models.FileField() |
20 | 21 | choices = models.CharField(max_length=10, choices='bad') |
21 | 22 | choices2 = models.CharField(max_length=10, choices=[(1,2,3),(1,2,3)]) |
… |
… |
invalid_models.fielderrors: "decimalfield3": DecimalFields require a "decimal_pl
|
245 | 246 | invalid_models.fielderrors: "decimalfield3": DecimalFields require a "max_digits" attribute that is a positive integer. |
246 | 247 | invalid_models.fielderrors: "decimalfield4": DecimalFields require a "max_digits" attribute value that is greater than the value of the "decimal_places" attribute. |
247 | 248 | invalid_models.fielderrors: "decimalfield5": DecimalFields require a "max_digits" attribute value that is greater than the value of the "decimal_places" attribute. |
| 249 | invalid_models.fielderrors: "decimalfield6": DecimalFields require a "default" attribute that is of type Decimal. |
248 | 250 | invalid_models.fielderrors: "filefield": FileFields require an "upload_to" attribute. |
249 | 251 | invalid_models.fielderrors: "choices": "choices" should be iterable (e.g., a tuple or list). |
250 | 252 | invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-tuples. |