#16612: Localized form fields cause Form.has_changed() to always return True. -------------------------------------+------------------------ Reporter: rviotti@… | Owner: nobody Type: Bug | Status: new Milestone: | Component: Forms Version: 1.3 | Severity: Normal Resolution: | Keywords: Triage Stage: Accepted | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------ Changes (by aaugustin):
* needs_better_patch: => 0 * needs_docs: => 0 * needs_tests: => 0 * stage: Unreviewed => Accepted Comment: This looks similar to the problems reported for !DateTimeField reported in #12858 and for !NullBooleanField in #11860. It's clear that this bug exists for !DecimalField. Localization happens in the template, when the widget is rendered; fields and widgets' `initial_data` always contain the unlocalized object. But submitted data is localized. So `Widget._has_changed` compares localized and unlocalized data, and fails. "Unlocalization" of the submitted value happens later, in `DecimalField.to_python`. Generally, I don't understand why the "has_changed" logic is implemented in the widgets. It seems to me that "has_changed" is data-related (= field), not presentation-related (= widget). To compute it, we need the "unlocalized" value, ie. the output of `Field.to_python`. I think this logic should be moved from `forms.Widget` and its subclasses to `forms.Field` and its subclasses. -- Ticket URL: <https://code.djangoproject.com/ticket/16612#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.