Changes between Version 8 and Version 11 of Ticket #32559


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

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32559 – Description

    v8 v11  
    1 If 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 
    5 Since the HTML standard offers a `step` attribute on input fields of `type="number"`,
    6 this feature shall be reflected by Django's `FloatField` and  optionally `DecimalField`,
    7 rather than having to parametrize the widget.
    8 
    9 Min- and max-values are already supported by the `FloatField`, so the step-value
    10 would make sense here as well. It furthermore would require to revalidate the
    11 step-value by Django's Form validation, rather than by HTML alone.
    12 
    13 Patch: https://github.com/django/django/pull/14162
     1I 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.
Back to Top