-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Add localize keyword argument to DecimalField
#4233
Conversation
Current coverage is 91.20%@@ master #4233 diff @@
==========================================
Files 51 52 +1
Lines 5551 5779 +228
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 5082 5271 +189
- Misses 469 508 +39
Partials 0 0
|
return float(value) | ||
value = float(value) | ||
if self.localize: | ||
value = localize_input(value) |
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.
Localizing the output doesn't make sense here. FloatField should represent as floats, not as a localized string.
In a slight change to my previous comment the actual behavior that we'd want if we do decide to support this should be to only apply localization to numbers which are represented in string format. Changes needed before we could consider this pull request
|
@@ -923,7 +927,12 @@ def to_internal_value(self, data): | |||
Validate that the input is a decimal number and return a Decimal | |||
instance. | |||
""" | |||
|
|||
if self.localize: | |||
data = sanitize_separators(data) |
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.
I think this would make slightly more sense after the smart_text
/.strip()
line below.
DecimalField
Nice work. |
Description
Added support for localized decimal and float fields.
Addresses #2897