There seem to be a max_length
for CharField
only. But how about min_length
for a TextField()
, is there a way to enforce 100 characters in the TextField
?
Django tip: Use models. TextField for storing long texts inside your models instead of models. CharField since CharField has a max length of 255 characters while TextField can hold more than 255 characters.
TextField is a field used to create an arbitrary amount of text characters in a database column defined by the Django ORM. The Django project has wonderful documentation for TextField and all of the other column fields. Note that TextField is defined within the django.
TextField is a large text field for large-sized text. TextField is generally used for storing paragraphs and all other text data. The default form widget for this field is TextArea.
You would use a custom validator, specifically MinLengthValidator
When declaring a Django form
cell_phone=forms.CharField(max_length=10,min_length=10);
When rendering a form field in Django template
{% render_field form1.cell_phone minlength="10" maxlength="10" %}
Underscore is confusing
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