#NEWLINE# def get_form( self , request , obj = None , **kwargs ) : #NEWLINE# #INDENT# '\n        Returns a Form class for use in the admin add view. This is used by\n        add_view and change_view.\n        ' #NEWLINE# if ( 'fields' in kwargs ) : #NEWLINE# #INDENT# fields = kwargs . pop ( 'fields' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fields = flatten_fieldsets ( self . get_fieldsets ( request , obj ) ) #NEWLINE# #UNINDENT# if ( self . exclude is None ) : #NEWLINE# #INDENT# exclude = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# exclude = list ( self . exclude ) #NEWLINE# #UNINDENT# exclude . extend ( self . get_readonly_fields ( request , obj ) ) #NEWLINE# if ( ( self . exclude is None ) and hasattr ( self . form , '_meta' ) and self . form . _meta . exclude ) : #NEWLINE# #INDENT# exclude . extend ( self . form . _meta . exclude ) #NEWLINE# #UNINDENT# exclude = ( exclude or None ) #NEWLINE# defaults = { #NEWLINE# #INDENT# 'form' : self . form , #NEWLINE# 'fields' : fields , #NEWLINE# 'exclude' : exclude , #NEWLINE# 'formfield_callback' : partial ( self . formfield_for_dbfield , request = request ) , #NEWLINE# #UNINDENT# } #NEWLINE# defaults . update ( kwargs ) #NEWLINE# if ( ( defaults [ 'fields' ] is None ) and ( not modelform_defines_fields ( defaults [ 'form' ] ) ) ) : #NEWLINE# #INDENT# defaults [ 'fields' ] = None #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return documentform_factory ( self . model , ** defaults ) #NEWLINE# #UNINDENT# except FieldError as e : #NEWLINE# #INDENT# raise FieldError ( ( '%s. Check fields/fieldsets/exclude attributes of class %s.' % ( e , self . __class__ . __name__ ) ) )