Code

Opened 8 years ago

Closed 8 years ago

#2660 closed defect (invalid)

FloatField cant be edited in admin.

Reported by: aagaande@… Owned by: adrian
Component: contrib.admin Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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.

Attachments (0)

Change History (1)

comment:1 Changed 8 years ago by ubernostrum

  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.