-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Add localization support for all number fields (Issue #4584) #4586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…r, Float,Decimal) that handles a localize and coerce_to_string parameter as it was done in the DecimalField. Add API settings to handles default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff here, tho see comment. We can consider this after that change.
@@ -873,20 +875,28 @@ def to_internal_value(self, data): | |||
|
|||
# Number types... | |||
|
|||
class IntegerField(Field): | |||
|
|||
class NumberField(Field): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change footprint of this pull request is fairly large given that it introduces a new base class here. I'd be interested in seeing the equivalent pull request without introducing a new base class. We could then consider if we want a NumberField
as a separate feature request, since that's really a different issue to numeric localisation support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I clearly understand what you mean... You'll prefer that I just patch the FloatField (which is the starting point of the localization problem) to work like the DecimalField with possible code duplication than using a new base class? I agree that will have a lower impact and it could be a less "risky" change. Do I understand right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, yup. We could consider a new base class, but that's a separate issue.
Closing in favor of #4925. |
Description
Full description of the issue can be found here: Issue #4584.
The goals of this pull request is add the localize and coerce_to_string parameters, which are available with the DecimalField, to the IntegerField and the FloatField.
By creating a base NumberField, with this patch, now all number fields can generate localized string values as representation, and can parse localized numbers by sanitizing the text input the same way it was done in the DecimalField.
refs #4584