#NEWLINE# def yes_no_formatter( value , **_ ) : #NEWLINE# #INDENT# ' Handle True/False from Django model and 1/0 from raw sql ' #NEWLINE# if ( ( _ is True ) or ( value == 1 ) ) : #NEWLINE# #INDENT# return 'Yes' #NEWLINE# #UNINDENT# if ( ( value is False ) or ( value == 0 ) ) : #NEWLINE# #INDENT# return 'No' #NEWLINE# #UNINDENT# if ( value is None ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# assert False , 'Unable to convert {} to Yes/No' . format ( value )