#NEWLINE# def formfield_for_dbfield( self , db_field , **kwargs ) : #NEWLINE# #INDENT# "\n        Hook for specifying the form Field instance for a given database Field\n        instance.\n\n        If kwargs are given, they're passed to the form Field's constructor.\n        " #NEWLINE# request = kwargs . pop ( 'request' , None ) #NEWLINE# if db_field . choices : #NEWLINE# #INDENT# return self . formfield_for_choice_field ( db_field , request , ** kwargs ) #NEWLINE# #UNINDENT# if isinstance ( db_field , ( models . ForeignKey , models . ManyToManyField ) ) : #NEWLINE# #INDENT# if ( db_field . __class__ in self . formfield_overrides ) : #NEWLINE# #INDENT# kwargs = dict ( self . formfield_overrides [ db_field . __class__ ] , ** kwargs ) #NEWLINE# #UNINDENT# if isinstance ( db_field , models . ForeignKey ) : #NEWLINE# #INDENT# formfield = self . formfield_for_foreignkey ( db_field , request , ** kwargs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( db_field , models . ManyToManyField ) : #NEWLINE# #INDENT# formfield = self . formfield_for_manytomany ( db_field , request , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# if ( formfield and ( db_field . name not in self . raw_id_fields ) ) : #NEWLINE# #INDENT# related_modeladmin = self . admin_site . _registry . get ( db_field . rel . to ) #NEWLINE# can_add_related = bool ( ( related_modeladmin and related_modeladmin . has_add_permission ( request ) ) ) #NEWLINE# formfield . widget = widgets . RelatedFieldWidgetWrapper ( formfield . widget , db_field . rel , self . admin_site , can_add_related = can_add_related ) #NEWLINE# #UNINDENT# return formfield #NEWLINE# #UNINDENT# for klass in db_field . __class__ . mro ( ) : #NEWLINE# #INDENT# if ( klass in self . formfield_overrides ) : #NEWLINE# #INDENT# kwargs = dict ( copy . deepcopy ( self . formfield_overrides [ klass ] ) , ** kwargs ) #NEWLINE# return db_field . formfield ( ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# return db_field . formfield ( ** kwargs )