#NEWLINE# def formfield( field , form_class = None , **kwargs ) : #NEWLINE# #INDENT# '\n    Returns a django.forms.Field instance for this database Field.\n    ' #NEWLINE# defaults = { #NEWLINE# #INDENT# 'required' : field . required , #NEWLINE# #UNINDENT# } #NEWLINE# if ( field . default is not None ) : #NEWLINE# #INDENT# if isinstance ( field . default , collections . Callable ) : #NEWLINE# #INDENT# defaults [ 'initial' ] = field . default ( ) #NEWLINE# defaults [ 'show_hidden_initial' ] = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# defaults [ 'initial' ] = field . default #NEWLINE# #UNINDENT# #UNINDENT# if ( field . choices is not None ) : #NEWLINE# #INDENT# for k in list ( kwargs . keys ( ) ) : #NEWLINE# #INDENT# if ( k not in ( 'coerce' , 'empty_value' , 'choices' , 'required' , 'widget' , 'label' , 'initial' , 'help_text' , 'error_messages' , 'show_hidden_initial' ) ) : #NEWLINE# #INDENT# del kwargs [ k ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# defaults . update ( kwargs ) #NEWLINE# if ( k is not None ) : #NEWLINE# #INDENT# return form_class ( ** defaults ) #NEWLINE# #UNINDENT# return _fieldgenerator . generate ( field , ** defaults )