Code

#19557 closed Bug (duplicate)

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

Reported by: jrief 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 jrief 16 months ago.
patch

Download all attachments as: .zip

Change History (7)

Changed 16 months ago by jrief

patch

comment:1 Changed 16 months 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:2 Changed 16 months ago by mjtamlyn

  • Needs tests set

comment:3 Changed 16 months ago by claudep

  • Resolution set to duplicate
  • Status changed from new to closed

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

comment:4 Changed 10 months ago by jrief

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 Changed 10 months ago by jrief

  • Resolution duplicate deleted
  • Status changed from closed to new

comment:6 Changed 10 months ago by lukeplant

  • Resolution set to duplicate
  • Status changed from new to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.