Opened 18 years ago
Closed 18 years ago
#2660 closed defect (invalid)
FloatField cant be edited in admin.
Reported by: | 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.
Note:
See TracTickets
for help on using tickets.
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 thatdecimal_places
can't do much for you -- as soon as you enter the "5" you've got one total digit andmax_digits
won't let you enter any more. If you need to store a number of the form "5.5", you needmax_digits=2, decimal_places=1
.