Convert DecimalField to String rather than Float · Issue #91 · graphql-python/graphene-django (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Description
DecimalField entries are currently being converted to Float (
@convert_form_field.register(forms.DecimalField) |
---|
@convert_form_field.register(forms.FloatField) |
def convert_form_field_to_float(field): |
return Float(description=field.help_text, required=field.required) |
)
Full support for Decimal would be great, but in the meantime I propose that DecimalField should be converted to String instead. Once you've converted a Decimal to a Float, you've probably lost the benefit of why you used Decimal in the first place, since you'll now have values like 3.14000000000000012
, rather than 3.14
. If it is converted to String, it is simple enough for the user to convert that String back to Decimal, whereas converting from Float to Decimal is not straightforward.