#NEWLINE# @ register . filter ( name = 'add_css' ) #NEWLINE# def add_css( field , css ) : #NEWLINE# #INDENT# custom_attrs = field . field . widget . attrs #NEWLINE# if ( not custom_attrs . get ( 'class' , None ) ) : #NEWLINE# #INDENT# custom_attrs [ 'class' ] = css #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# custom_attrs [ 'class' ] += ( ' ' + css ) #NEWLINE# #UNINDENT# return field . as_widget ( attrs = custom_attrs )