I\'m iterating through the fields of a form and for certain fields I want a slightly different layout, requiring altered HTML.
To do this accurately, I just need to
Following the answer from Oli and rinti: I used this one and I think it is a bit simpler:
template code: {{ field|fieldtype }}
{{ field|fieldtype }}
filter code:
from django import template register = template.Library() @register.filter('fieldtype') def fieldtype(field): return field.field.widget.__class__.__name__