forms.widgets.Widget._has_changed() erroneously returns True on Widgets with is_localized=True
|Reported by:||jrief||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||no|
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.
Change History (7)
Changed 2 years ago by jrief
comment:1 Changed 2 years ago by anonymous
- Component changed from Uncategorized to Forms
- Has patch set
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Type changed from Uncategorized to Bug
comment:3 Changed 2 years ago by claudep
- Resolution set to duplicate
- Status changed from new to closed
comment:5 Changed 23 months ago by jrief
- Resolution duplicate deleted
- Status changed from closed to new