We could generate the same input in a Django form with
`IntegerField(min_value=1, step_size=2)` and `Field.localize` is `False`,
which would then use `MinValueValidator` and `StepValueValidator`.
We then get into a problem as `StepValueValidator` always uses `0` as the
base, so `step_size=2` only even numbers are allowed. This then conflicts
with the client side validation, and the user cannot submit any value for
the input.
I'm unsure if this is a bug or whether this is just a configuration
problem, apologies if so, but the behaviour does seem to me to conflict
with how min and step is handled by browsers.
--
Ticket URL: <https://code.djangoproject.com/ticket/34473>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: Jacob Rief, Kapil Bansal (added)
* type: Uncategorized => Bug
* component: Uncategorized => Forms
* stage: Unreviewed => Accepted
Comment:
Thanks for the report! As far as I'm aware we should pass `min_value` to
the `StepValueValidator`. Bug in 3a82b5f655446f0ca89e3b6a92b100aa458f348f.
--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:1>
Comment (by Kapil Bansal):
Thanks for the report. I think this is a bug. We need to consider min
value also with step_size
--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:2>
* owner: nobody => Jacob Rief
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:3>
Comment (by Jacob Rief):
There is a patch: https://github.com/django/django/pull/16742
will be fixed in Django-5.0
--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:4>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:5>
* needs_better_patch: 0 => 1
* needs_docs: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:6>
* version: 4.1 => dev
Comment:
pull request has been fixed for dev branch
--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:7>
* needs_better_patch: 1 => 0
* needs_docs: 1 => 0
Comment:
Hello Jacob,
When the PR for this ticket is updated to the latest requests from
reviewers, ideally you should unset the ticket's flags "needs
documentation" and "patch needs improvement". That way, the PR will re-
appear in the list of branches needing re-review. I have unset these for
you now.
--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:8>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"1fe0b167af3611cca79e8a8092ee929312193c6f" 1fe0b16]:
{{{
#!CommitTicketReference repository=""
revision="1fe0b167af3611cca79e8a8092ee929312193c6f"
Fixed #34473 -- Fixed step validation for form fields with non-zero
minimum value.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:10>