In the Model
I set the maxlength of the field:
short_description = models.CharField(max_length=405)
In the ModelForm
in the widget attributes I set minlength an maxlength:
class ItemModelForm(forms.ModelForm):
class Meta:
model = Item
fields = ['name', 'short_description', 'description']
widgets = {
'name': TextInputWidget(attrs={'placeholder': 'Name*'}),
'short_description': TextareaWidget(attrs={'minlength': 200, 'maxlength': 400})
}
The issue in the HTML the minlegth is from the widget, but maxlength is still taken from the model(405 instead of 400).
I want the widget attribute to overwrite the model attribute.