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 4 years ago
  2. Advanced Search in django admin by visik7 1 year, 4 months ago
  3. BetterForm with fieldsets and row_attrs by carljm 3 years, 3 months ago
  4. Form row filter by kylefox 4 years, 3 months ago
  5. Custom CSS class in Form with template tag filter by kegan 2 years, 11 months ago

Comments

(Forgotten your password?)