[Django] #35433: NumberInput off-by-one on min value for type range

12 views
Skip to first unread message

Django

unread,
May 5, 2024, 1:22:50 AMMay 5
to django-...@googlegroups.com
#35433: NumberInput off-by-one on min value for type range
--------------------------------------+------------------------
Reporter: mitch99 | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
--------------------------------------+------------------------
Given this:


{{{
widgets = {
"weight": forms.NumberInput(attrs={'type':'range', 'step': '1', 'min':
'1', 'max': '5'),
}
}}}


I expect the min value on the range input to be 1, but it's actually 0:


{{{
<input type="range" name="form-2-weight" value="3" step="1" min="0"
max="5" aria-describedby="id_form-2-weight_helptext"
id="id_form-2-weight">
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35433>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 5, 2024, 6:20:55 AMMay 5
to django-...@googlegroups.com
#35433: NumberInput off-by-one on min value for type range
-------------------------+--------------------------------------
Reporter: mitch99 | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------+--------------------------------------
Changes (by Sarah Boyce):

* resolution: => needsinfo
* status: new => closed

Comment:

This is missing information to determine whether this is a bug or not, I
need to see the how the form is defined and how the field weight is
defined on the model.
--
Ticket URL: <https://code.djangoproject.com/ticket/35433#comment:1>

Django

unread,
May 5, 2024, 3:03:24 PMMay 5
to django-...@googlegroups.com
#35433: NumberInput off-by-one on min value for type range
-------------------------+--------------------------------------
Reporter: mitch99 | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------+--------------------------------------
Comment (by mitch99):

Please see below:

{{{
class ContentProfileDefinitionForm(forms.ModelForm):
class Meta:
model = ContentProfileDefinition
fields = ["other", "weight"]
widgets = {
"weight": forms.NumberInput(
attrs={
"type": "range",
"step": "1",
"min": "1",
"max": "5",
}
),
}
}}}


{{{
class ContentProfileDefinition(models.Model):
other = models.ForeignKey("Other", on_delete=models.CASCADE)
weight = models.PositiveSmallIntegerField(
default=1,
help_text="Weight",
validators=[
MinValueValidator(1),
MaxValueValidator(5),
],
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35433#comment:2>

Django

unread,
May 5, 2024, 3:09:12 PMMay 5
to django-...@googlegroups.com
#35433: NumberInput off-by-one on min value for type range
-------------------------+--------------------------------------
Reporter: mitch99 | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------+--------------------------------------
Changes (by mitch99):

* resolution: needsinfo =>
* status: closed => new

Comment:

Unable to reopen so recreated at #35435
--
Ticket URL: <https://code.djangoproject.com/ticket/35433#comment:3>

Django

unread,
May 5, 2024, 3:26:16 PMMay 5
to django-...@googlegroups.com
#35433: NumberInput off-by-one on min value for type range
-------------------------+--------------------------------------
Reporter: mitch99 | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------+--------------------------------------
Comment (by mitch99):

Strangely it's not an off-by-one. It seems the min value is ignored and
always set to 0.
--
Ticket URL: <https://code.djangoproject.com/ticket/35433#comment:4>
Reply all
Reply to author
Forward
0 new messages