Opened 18 years ago

Closed 18 years ago

#2660 closed defect (invalid)

FloatField cant be edited in admin.

Reported by: aagaande@… Owned by: Adrian Holovaty
Component: contrib.admin Version: dev
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

Description

When adding the following FloatField to a model:
score = models.FloatField(blank=True,null=True,max_digits=1,decimal_places=1)
And setting it to for example 5.5, in the admin panel it will show as "5.". And if you try to save it it will complain with "Please enter a valid decimal number with a whole part of at most 0 digits."

I've checked the value, and it does store correctly, so the bug is in the admin panel.

Change History (1)

comment:1 by James Bennett, 18 years ago

Resolution: invalid
Status: newclosed

You have a bad combination of arguments there; max_digits=1 means "do not accept numbers with more than one total digit in them", which means that decimal_places can't do much for you -- as soon as you enter the "5" you've got one total digit and max_digits won't let you enter any more. If you need to store a number of the form "5.5", you need max_digits=2, decimal_places=1.

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