Example:
{{{
<input type="range" name="points" min="1" max="10">
}}}
It has following attributes:
{{{
max - specifies the maximum value allowed
min - specifies the minimum value allowed
step - specifies the legal number intervals
value - Specifies the default value
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20674>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_better_patch: => 0
* resolution: => wontfix
* needs_tests: => 0
* needs_docs: => 0
Comment:
I think the idea is that Django provides the most natural widget types for
each of its form fields, that's why we added the specialized new input
types (IntegerField -> NumberInput, EmailField -> EmailInput, URLField ->
URLInput).
Now we don't plan to cover the entire range of new input types as
individual widget classes, as it is so easy to create your own for your
needs. You can do that by either creating your own Input subclasses, or
even by specifying attributes in widget initialization:
{{{
count = forms.IntegerField(widget=NumberInput(attrs={'type':'range',
'step': '2'}))
}}}
See also https://docs.djangoproject.com/en/dev/ref/forms/widgets/#styling-
widget-instances
If you'd like to discuss that with a broader audience, feel free to bring
that topic on the django-developers mailing list.
--
Ticket URL: <https://code.djangoproject.com/ticket/20674#comment:1>
Comment (by bps):
Replying to [comment:1 claudep]:
> I think the idea is that Django provides the most natural widget types
for each of its form fields, that's why we added the specialized new input
types (IntegerField -> NumberInput, EmailField -> EmailInput, URLField ->
URLInput).
>
> Now we don't plan to cover the entire range of new input types as
individual widget classes, as it is so easy to create your own for your
needs. You can do that by either creating your own Input subclasses, or
even by specifying attributes in widget initialization:
> {{{
> count = forms.IntegerField(widget=NumberInput(attrs={'type':'range',
'step': '2'}))
> }}}
>
> See also https://docs.djangoproject.com/en/dev/ref/forms/widgets
/#styling-widget-instances
>
> If you'd like to discuss that with a broader audience, feel free to
bring that topic on the django-developers mailing list.
But RangeInput need validation on server side (max, min, step), like
NumberInput, EmailInput, URLInput. At the moment I must write custom
validators for range input ((.
--
Ticket URL: <https://code.djangoproject.com/ticket/20674#comment:2>
Comment (by claudep):
Replying to [comment:2 bps]:
> But RangeInput need validation on server side (max, min, step), like
NumberInput, EmailInput, URLInput. At the moment I must write custom
validators for range input ((.
For max and min, you should be able to use the current validators
available for IntegerField. For any more specialized validation like
`step`, providing a custom validator at form field level is the way to go.
It's not common enough to warrant integration in core, in my opinion.
--
Ticket URL: <https://code.djangoproject.com/ticket/20674#comment:3>