Skip to content

Instantly share code, notes, and snippets.

@TimFletcher
TimFletcher / gist:034e799c19eb763fa859
Created August 6, 2014 22:24
Django template filter to add attributes to form fields
# From http://vanderwijk.info/blog/adding-css-classes-formfields-in-django-templates/#comment-1193609278
from django import template
register = template.Library()
@register.filter(name='add_attributes')
def add_attributes(field, css):
attrs = {}
definition = css.split(',')