Reputation: 4318
CommandError: System check identified some issues:
ERRORS:
(fields.E132) DecimalFields must define a 'max_digits' attribute.
Is there a technical reason why max_digits
is a required attribute for Django's model field DecimalField
?
The docs say it used Python's [decimal][1]
module, but python object type doesn't seem to be bothered at all by anything to do with the absolute number of digits of the decimal object.
Maybe there's an opaque ORM reason?
FloatFields
(against which DecimalFields
are compared) don't require you to predetermine the number of digits so why decimals?
I know this small additional attribute shouldn't bother me but for some reason it's seemed unnecessary to me ever since the first time I used this field type.
Upvotes: 1
Views: 2420
Reputation: 37319
It's required by the database (not the ORM). SQL decimal
columns are declared with both precision (total number of significant digits) and scale (number of digits to the right of the decimal point).
See for instance the formal grammar quoted at this answer: https://stackoverflow.com/a/759606/2337736
Upvotes: 1