Ticket #7726: patch.diff
File patch.diff, 2.8 KB (added by , 14 years ago) |
---|
-
django/core/management/validation.py
67 67 e.add(opts, mdigits_msg % f.name) 68 68 except (ValueError, TypeError): 69 69 e.add(opts, mdigits_msg % f.name) 70 improperly_configured_msg = '"%s": DecimalFields require a "max_digits" attribute that is higher than "decimal_places" attribute.' 71 try: 72 max_digits = int(f.max_digits) 73 decimal_places = int(f.decimal_places) 74 if (max_digits > 0) and (decimal_places >=0): 75 if not (max_digits > decimal_places): 76 e.add(opts, improperly_configured_msg % f.name) 77 except (ValueError, TypeError): 78 pass 70 79 if isinstance(f, models.FileField) and not f.upload_to: 71 80 e.add(opts, '"%s": FileFields require an "upload_to" attribute.' % f.name) 72 81 if isinstance(f, models.ImageField): -
tests/modeltests/invalid_models/models.py
14 14 decimalfield = models.DecimalField() 15 15 decimalfield2 = models.DecimalField(max_digits=-1, decimal_places=-1) 16 16 decimalfield3 = models.DecimalField(max_digits="bad", decimal_places="bad") 17 decimalfield4 = models.DecimalField(max_digits=9, decimal_places=10) 18 decimalfield5 = models.DecimalField(max_digits=10, decimal_places=10) 17 19 filefield = models.FileField() 18 20 choices = models.CharField(max_length=10, choices='bad') 19 21 choices2 = models.CharField(max_length=10, choices=[(1,2,3),(1,2,3)]) … … 241 243 invalid_models.fielderrors: "decimalfield2": DecimalFields require a "max_digits" attribute that is a positive integer. 242 244 invalid_models.fielderrors: "decimalfield3": DecimalFields require a "decimal_places" attribute that is a non-negative integer. 243 245 invalid_models.fielderrors: "decimalfield3": DecimalFields require a "max_digits" attribute that is a positive integer. 246 invalid_models.fielderrors: "decimalfield4": DecimalFields require a "max_digits" attribute that is higher than "decimal_places" attribute. 247 invalid_models.fielderrors: "decimalfield5": DecimalFields require a "max_digits" attribute that is higher than "decimal_places" attribute. 244 248 invalid_models.fielderrors: "filefield": FileFields require an "upload_to" attribute. 245 249 invalid_models.fielderrors: "choices": "choices" should be iterable (e.g., a tuple or list). 246 250 invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-tuples.