Opened 5 weeks ago

Closed 5 weeks ago

#35445 closed Bug (invalid)

Adding model field validators to FloatField and IntegerField is not possible.

Reported by: AjmalPonneth Owned by: AjmalPonneth
Component: Core (Other) Version: 5.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Adding validators like MinLengthValidator, and MaxLengthValidator to the float field causes a TypeError "object of type 'float' has no len()" when saving the instance from admin.

Change History (1)

comment:1 by Sarah Boyce, 5 weeks ago

Component: Database layer (models, ORM)Core (Other)
Resolution: invalid
Status: assignedclosed

Hi AjmalPonneth,
MinLengthValidator and MaxLengthValidator are not meant to be used for floats as it is checking the length. You may want to use MinValueValidator and MaxValueValidator.
If you want to make some tweaks to the docs around which types the validators can be used for, feel free 👍

Note: See TracTickets for help on using tickets.
Back to Top