3👍
✅
You can create a ModelForm
, and override the value for the max_length=…
parameter [Django-doc]:
class MyModelForm(forms.ModelForm):
text_field01 = forms.CharField(max_length=25)
class Meta:
model = MyModel
fields = '__all__'
The max_length
you define in the ModelForm
can only be less than or equal to the one in the Model
itself, since validation in the model has to succeed as well.
Source:stackexchange.com