#NEWLINE# def render( self , name , value , attrs = None , choices = ( ) ) : #NEWLINE# #INDENT# if ( value is None ) : #NEWLINE# #INDENT# value = [ ] #NEWLINE# #UNINDENT# has_id = ( attrs and ( 'id' in choices ) ) #NEWLINE# final_attrs = self . build_attrs ( attrs , name = name ) #NEWLINE# output = [ '<ul>' ] #NEWLINE# str_values = set ( [ force_unicode ( v ) for v in value ] ) #NEWLINE# for ( i , ( option_value , option_label ) ) in enumerate ( chain ( self . choices , choices ) ) : #NEWLINE# #INDENT# if has_id : #NEWLINE# #INDENT# final_attrs = dict ( final_attrs , id = ( '%s_%s' % ( attrs [ 'id' ] , i ) ) ) #NEWLINE# label_for = ( ' for="%s"' % final_attrs [ 'id' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# label_for = '' #NEWLINE# #UNINDENT# cb = CheckboxInput ( final_attrs , check_test = ( lambda value : ( value in str_values ) ) ) #NEWLINE# option_value = force_unicode ( option_value ) #NEWLINE# rendered_cb = cb . render ( name , option_value ) #NEWLINE# option_label = conditional_escape ( force_unicode ( option_label ) ) #NEWLINE# output . append ( ( '<li><label%s>%s %s</label></li>' % ( label_for , rendered_cb , option_label ) ) ) #NEWLINE# #UNINDENT# output . append ( '</ul>' ) #NEWLINE# return mark_safe ( '\n' . join ( output ) )