#NEWLINE# def as_widget( self , widget = None , attrs = None , only_initial = False ) : #NEWLINE# #INDENT# "\n        Renders the field by rendering the passed widget, adding any HTML\n        attributes passed as attrs.  If no widget is specified, then the\n        field's default widget will be used.\n        " #NEWLINE# if ( not widget ) : #NEWLINE# #INDENT# widget = self . field . widget #NEWLINE# #UNINDENT# if self . field . localize : #NEWLINE# #INDENT# widget . is_localized = True #NEWLINE# #UNINDENT# attrs = ( attrs or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( ( not widget . is_hidden ) and self . field . required and self . form . use_required_attribute ) : #NEWLINE# #INDENT# attrs [ 'required' ] = True #NEWLINE# #UNINDENT# if self . field . disabled : #NEWLINE# #INDENT# attrs [ 'disabled' ] = True #NEWLINE# #UNINDENT# auto_id = self . auto_id #NEWLINE# if ( auto_id and ( 'id' not in attrs ) and ( 'id' not in widget . attrs ) ) : #NEWLINE# #INDENT# if ( not only_initial ) : #NEWLINE# #INDENT# attrs [ 'id' ] = auto_id #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# attrs [ 'id' ] = self . html_initial_id #NEWLINE# #UNINDENT# #UNINDENT# if ( not only_initial ) : #NEWLINE# #INDENT# name = self . html_name #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# name = self . html_initial_name #NEWLINE# #UNINDENT# return force_text ( widget . render ( name , self . value ( ) , attrs = attrs ) )