Opened 7 years ago

Closed 7 years ago

#19557 closed Bug (duplicate)

forms.widgets.Widget._has_changed() erroneously returns True on Widgets with is_localized=True

Reported by: Jacob Rief Owned by: nobody
Component: Forms Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


How to reproduce:
In set USE_L10N=True and set your locale to a language which uses a comma as decimal separator.
Create a form with fields for Float or Decimal and give them an initial value.
On the corresponding widget, set is_localized=True.

If this form is rendered, the initial values are displayed using a comma instead of a dot. If the client resubmits this form without changing any value, the method forms.widgets.Widget._has_changed() erroneously returns True, because it compares a decimal string using a comma as decimal separator (from the input field) with a string using a dot (from the initial value).

The attached patch worked for me.

Attachments (1)

django-widget-has_changed.patch (958 bytes) - added by Jacob Rief 7 years ago.

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by Jacob Rief


comment:1 Changed 7 years ago by anonymous

Component: UncategorizedForms
Has patch: set
Type: UncategorizedBug

comment:2 Changed 7 years ago by Marc Tamlyn

Needs tests: set

comment:3 Changed 7 years ago by Claude Paroz

Resolution: duplicate
Status: newclosed

Thanks, but this has already been reported in #16612.

comment:4 Changed 7 years ago by Jacob Rief

In the 1.4.x stable branch, this bug still exists. When I filed it, it was on Version 1.4.3, now we have 1.4.5 and this bug still is there.

I noticed, that in Django>=1.5 a lot of code regarding this has been modified, but I can not upgrade to 1.5 yet and it is somehow embarrassing always having to patch Django-1.4.x manually to fix this.

I filed a pull request on github for this:

comment:5 Changed 7 years ago by Jacob Rief

Resolution: duplicate
Status: closednew

comment:6 Changed 7 years ago by Luke Plant

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top