Opened 11 years ago

Closed 11 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

Description

How to reproduce:
In settings.py 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 11 years ago.
patch

Download all attachments as: .zip

Change History (7)

by Jacob Rief, 11 years ago

patch

comment:1 by anonymous, 11 years ago

Component: UncategorizedForms
Has patch: set
Type: UncategorizedBug

comment:2 by Marc Tamlyn, 11 years ago

Needs tests: set

comment:3 by Claude Paroz, 11 years ago

Resolution: duplicate
Status: newclosed

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

comment:4 by Jacob Rief, 11 years ago

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: https://github.com/django/django/pull/1268

comment:5 by Jacob Rief, 11 years ago

Resolution: duplicate
Status: closednew

comment:6 by Luke Plant, 11 years ago

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