views:

44

answers:

0

Hi,

In my generic form template, if a CharField has a max_length attribute, I display that beside the field.

Form template:

{% if field.field.max_length %}
    Max. {{ field.field.max_length }} char.
{% endif %}

I want to do this for TextFields, where max_length is not used, defined like that in the model:

class Entry(models.Model):
    ...
    body = models.TextField(validators=[MaxLengthValidator(1000)])

For ModelForm's, Is it possible to access the validators' max value to you in the templates?

Cheers,

omat