georgebv / drf-pydantic

Use pydantic with the Django REST framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't use DecimalFields

thommor opened this issue · comments

Having a model with a Decimal field is converted to a DecimalField in the serializer but a DecimalField requires max_digits and decimal_places to be provided, which is currently not supported.

You can provide max_digits and decimal_places to the field:

amount: Decimal = Field(max_digits=10, decimal_places=2) 

but these values do not get propagated to the serializer field.

Also of note is that the above method has a type of ConstrainedDecimal which does not exist in the FIELD_MAP