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

More like this

  1. order_by template filter by marinho 5 years ago
  2. Cookie based flash errors and notices (a la Rails) by alexk 4 years, 8 months ago
  3. Templatetag startswith + message tuned by io_error 4 years, 11 months ago
  4. Admin Input Field Character Count via jQuery by joshman 4 years, 5 months ago
  5. Git Revision Template Tag by sbaechler 6 months, 1 week ago

Comments

(Forgotten your password?)