Changes between Version 11 and Version 12 of Ticket #32559


Ignore:
Timestamp:
May 24, 2021, 3:45:44 PM (3 years ago)
Author:
Jacob Rief
Comment:

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.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32559 – Description

    v11 v12  
    1 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.
     1If someone wants to use the `step` attribute as provided by the HTML field
     2`<input type="number" ...>` , she/he has to specify that using for instance
     3`FloatField(widget=NumberInput(attrs={'step': 0.5}))`.
     4
     5Since the HTML standard offers a `step` attribute on input fields of `type="number"`,
     6this feature shall be reflected by Django's `FloatField` and  optionally `DecimalField`,
     7rather than having to parametrize the widget.
     8
     9Min- and max-values are already supported by the `FloatField`, so the step-value
     10would make sense here as well. It furthermore would require to revalidate the
     11step-value by Django's Form validation, rather than by HTML alone.
     12
     13Patch: https://github.com/django/django/pull/14162
Back to Top