Some attributes such as IntegerField.min_value need to be customized on the 
field rather than the widget. This will ensure that validation is also done 
server-side. (see 
https://github.com/django/django/blob/f3595b25496691966d4ff858a3b395735ad85a6e/django/forms/fields.py#L278-L285
 
for example)

On Thursday, March 31, 2016 at 11:47:34 AM UTC-4, Denis Makarov wrote:
>
> Hello!
>
> I have my own ModelForm with widgets in Meta class.
>
> class Meta:
>
>  model = Foods 
>
>  fields = '__all__' 
>
>  widgets = { 
>
>  'quantity': NumberInput(attrs={'min': 1, 'max': 10, 'name': "quantity2"
> }), 
>
>  'comment': TextInput(), 
>
>  }
>
>
> My quantity field have NumberInput as standard.
>
> I want to redefine html properties such name and min value.
>
> But when I did this (code above), my fiend quantity have old values (name 
> and min value). Max value correct.
>
> <p><label for="id_quantity">Quantity:</label> <input id="id_quantity" 
> max="10" min="0" name="quantity" type="number" value="1" /></p>
>
> Django (1.9.4)
>
> What's wrong?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c25f5b58-f5bc-4e31-aa67-f763bef60034%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to