#NEWLINE# @ register . filter #NEWLINE# def field_attrs( field_inst , **kwargs ) : #NEWLINE# #INDENT# 'Adds html attributes to django form fields' #NEWLINE# for ( k , v ) in kwargs . items ( ) : #NEWLINE# #INDENT# if ( v is not None ) : #NEWLINE# #INDENT# field_inst . field . widget . attrs [ k ] = v #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# del field_inst . field . widget . attrs [ k ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return field_inst