Code

Opened 2 years ago

Closed 18 months ago

Last modified 7 months ago

#18509 closed Bug (wontfix)

Bug: forms.DecimalField doesn't validate correctly when localized. (Unittest attached)

Reported by: serge_spaolonzi Owned by: nobody
Component: Forms Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

forms.DecimalField doesn't validate correctly when localized.
A form DecimalField is expected to validate invalid values when the method to python is called.
It throws a ValidationError for non localized instances when an incorrect value is introduced.
But for localized instances that are expected to accept a comma (,) as decimal separator it doesn't throw any exception for a value with a dot (.) and take it as valid.

Unittest attached

Attachments (1)

tests.py (802 bytes) - added by serge_spaolonzi 2 years ago.

Download all attachments as: .zip

Change History (5)

Changed 2 years ago by serge_spaolonzi

comment:1 Changed 2 years ago by serge_spaolonzi

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Bug: forms.DecimalField doesn't validate correctly when localized. (Unittest) to Bug: forms.DecimalField doesn't validate correctly when localized. (Unittest attached)

comment:2 Changed 2 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Design decision needed

The input isn't ambiguous: both "123.45" and "123,45" represent Decimal("123.45").

I don't see much value in rejecting the first form, especially when Django historically accepts it. I would go as far as to say it isn't worth the backwards incompatibility.

Last edited 2 years ago by aaugustin (previous) (diff)

comment:3 Changed 18 months ago by claudep

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

I do agree with Aymeric. Unless we miss a problematic use case, I don't think this is an issue. Reopen if you can show us that this can cause bugs.

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.