I currently have this sort of field in my model: motivation = models.TextField(max_length=10_000, validators=[ MinLengthValidator( 100)]) And I am using CreateView with this model. The form generated by this view has maxlength html attribute derived from the model's max_length, and it makes for good UX. However there is no minlength attribute. So the user has to send the request and only then get the error message after the validation. The workaround would be something like overriding form field in the custom model form to specify min_length yourself or adding custom help_text to indirectly solve the problem, but I think it should work out of the box. As far as i know, the CreateView uses ModelForm, so it's a problem with that class rather.
Could ModelForm automatically generate form fields with minlength attribute, probably based on MinLengthValidator in model? Or maybe add a min_length attribute for model fields and use it in the same way as max_length, because I don't see a reason why there is max_length, but no min_length. -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/803a6cd3-67a8-4619-9222-ccc412799bffn%40googlegroups.com.