Template Filter attr

1
2
3
4
5
6
7
8
9
from django import template

register = template.Library()

@register.filter_function
def attr(obj, arg1):
    att, value = arg1.split("=")
    obj.field.widget.attrs[att] = value
    return obj

Comments

(Forgotten your password?)

You may use Markdown syntax here, but raw HTML will be removed.