Accessing model field validators from within form template
Hi,
In my generic form template, if a CharField has a max_length
attribute, I display that beside the form field:
{% if field.field.max_length %}
Max. {{ field.field.max_length }} char.
{% endif %}
I want to do the same for TextFields, where max_length is not used,
but the max limit is set by a validator like that in the model:
class Entry(models.Model):
...
body = models.TextField(validators=[MaxLengthValidator(1000)])
For ModelForm, is it possible to access the validators' max value from
within the templates similar to this:
{{ field.validators[0].max_length }}
Cheers,
omat
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home