@register.filter
def field_attrs(field_inst, **kwargs):
    """Adds html attributes to django form fields"""
    for k, v in kwargs.items():
        if v is not None:
            field_inst.field.widget.attrs[k] = v
        else:
            try:
                del field_inst.field.widget.attrs[k]
            except __HOLE__:
                pass
    return field_inst
dataset/ETHPy150Open jbalogh/jingo/jingo/helpers.py/field_attrs