Opened 3 years ago

Closed 3 years ago

Last modified 21 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 3 years ago.

Download all attachments as: .zip

Change History (5)

Changed 3 years ago by serge_spaolonzi

comment:1 Changed 3 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 3 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 Django historically accepts it. I would go as far as to say it isn't worth the backwards incompatibility.

Version 1, edited 3 years ago by aaugustin (previous) (next) (diff)

comment:3 Changed 3 years 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.

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