Opened 12 years ago
Closed 12 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)
Change History (7)
by , 12 years ago
Attachment: | django-widget-has_changed.patch added |
---|
comment:1 by , 12 years ago
Component: | Uncategorized → Forms |
---|---|
Has patch: | set |
Type: | Uncategorized → Bug |
comment:2 by , 12 years ago
Needs tests: | set |
---|
comment:3 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Thanks, but this has already been reported in #16612.
comment:4 by , 12 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 , 12 years ago
Resolution: | duplicate |
---|---|
Status: | closed → new |
comment:6 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
We don't backport bug fixes of this nature, sorry. https://docs.djangoproject.com/en/1.5/internals/release-process/#supported-versions
patch