#NEWLINE# def formfield( self , **kwargs ) : #NEWLINE# #INDENT# db = kwargs . pop ( 'using' , None ) #NEWLINE# if isinstance ( self . remote_field . model , six . string_types ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Cannot create form field for %r yet, because its related model %r has not been loaded yet' % ( self . name , self . remote_field . model ) ) ) #NEWLINE# #UNINDENT# defaults = { #NEWLINE# #INDENT# 'form_class' : forms . ModelChoiceField , #NEWLINE# 'queryset' : self . remote_field . model . _default_manager . using ( db ) , #NEWLINE# 'to_field_name' : self . remote_field . field_name , #NEWLINE# #UNINDENT# } #NEWLINE# defaults . update ( kwargs ) #NEWLINE# return super ( ForeignKey , self ) . formfield ( ** defaults )