Skip to content

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

Closed
wants to merge 5 commits into from

Conversation

kgeorgy
Copy link

@kgeorgy kgeorgy commented Oct 17, 2016

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

Kevin Georgy and others added 3 commits October 17, 2016 14:00
…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.
Copy link
Member

@tomchristie tomchristie left a 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):
Copy link
Member

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.

Copy link
Author

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?

Copy link
Member

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.

@tomchristie
Copy link
Member

Closing in favor of #4925.

@tomchristie tomchristie removed this from the 3.6.4 Release milestone Jul 13, 2017
@kgeorgy kgeorgy deleted the localizednumberfields branch October 4, 2017 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants