#36673: DecimalField max_digits and decimal_places should be optional and more
general
----------------------------+-----------------------------------------
Reporter: Gavin Wahl | Type: Uncategorized
Status: new | Component: Uncategorized
Version: 5.2 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-----------------------------------------
In Postgres and the SQL standard, it is not necessary to define a
precision and scale for NUMERIC/DECIMAL fields. However, Django requires
that they be specified.
https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-
NUMERIC-DECIMAL
I would like to be able to create an unconstrained NUMERIC field with
`DecimalField()`, but Django gives the error:
{{{
(fields.E130) DecimalFields must define a 'decimal_places' attribute.
fields.E132) DecimalFields must define a 'max_digits' attribute.
}}}
Also, the precision needs to be allowed to be less than the scale.
`NUMERIC(1,2)` is a valid type that stores numbers of the form `-0.00,
-0.01,...0.08, 0.09` but Django says:
{{{
(fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/36673>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.