#32559: Add attribute 'step' to FloatField.
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Owner: Kapil
| Bansal
Type: New feature | Status: assigned
Component: Forms | Version: dev
Severity: Normal | Resolution:
Keywords: FloatField, | Triage Stage: Accepted
NumberInput, step |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Old description:
> I reviewed that pull request and after some testing I came to the
> conclusion, that `math.isclose` with a tolerance of `1e-9` is the best
> solution to fix the floating point rounding errors. All other approaches
> did not work properly or were far too complicated.
New description:
If someone wants to use the `step` attribute as provided by the HTML field
`<input type="number" ...>` , she/he has to specify that using for
instance
`FloatField(widget=NumberInput(attrs={'step': 0.5}))`.
Since the HTML standard offers a `step` attribute on input fields of
`type="number"`,
this feature shall be reflected by Django's `FloatField` and optionally
`DecimalField`,
rather than having to parametrize the widget.
Min- and max-values are already supported by the `FloatField`, so the
step-value
would make sense here as well. It furthermore would require to revalidate
the
step-value by Django's Form validation, rather than by HTML alone.
Patch: https://github.com/django/django/pull/14162
--
Comment (by Jacob Rief):
I reviewed that pull request and after some testing I came to the
conclusion, that `math.isclose` with a tolerance of `1e-9` is the best
solution to fix the floating point rounding errors. All other approaches
did not work properly or were far too complicated.
--
Ticket URL: <https://code.djangoproject.com/ticket/32559#comment:12>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.ec3fb99bd10f090b4eff32652f428dbb%40djangoproject.com.