Django Template Readonly Form Field

If I defined a form field to be readonly using code like this:

somefield = models.CharField(

how do I access the ‘readonly’ attribute in the Django template for the field, assuming I iterate over the fields in the form, like this:

{% for field in form %}
   {% if field ..... %}
   {% endif %}
{% endfor %}

Thank you.
1 Like

I think I found it:

{% field.field.widget.attrs.readonly %}


1 Like