#NEWLINE# def formfield( self , **kwargs ) : #NEWLINE# #INDENT# defaults = { #NEWLINE# #INDENT# 'form_class' : form_fields . GroupedModelSelect , #NEWLINE# 'queryset' : self . rel . to . _default_manager . complex_filter ( self . rel . limit_choices_to ) , #NEWLINE# 'to_field_name' : self . rel . field_name , #NEWLINE# 'order_field' : self . group_field , #NEWLINE# #UNINDENT# } #NEWLINE# defaults . update ( defaults ) #NEWLINE# return super ( ForeignKey , self ) . formfield ( ** defaults )