I have a form that is using NumberInput
widget to accept a rating for a Song from the user. The number should be between 0-5. My Song model has a MaxValueValidator
but I want the NumberInput
widget to show options only from 0-5.
In your form you can add min and max value which atleast shows the user the value should be between the limits.
rating = forms.CharField(label='Rating', widget=forms.TextInput(attrs={'min':1,'max': '5','type': 'number'}))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With