#NEWLINE# def test_commit_false( self ) : #NEWLINE# #INDENT# author1 = Author . objects . create ( name = 'Charles Baudelaire' ) #NEWLINE# author2 = Author . objects . create ( name = 'Paul Verlaine' ) #NEWLINE# author3 = Author . objects . create ( name = 'Walt Whitman' ) #NEWLINE# meeting = AuthorMeeting . objects . create ( created = date . today ( ) ) #NEWLINE# meeting . authors = Author . objects . all ( ) #NEWLINE# author4 = Author . objects . create ( name = 'John Steinbeck' ) #NEWLINE# AuthorMeetingFormSet = modelformset_factory ( AuthorMeeting , extra = 1 , can_delete = True ) #NEWLINE# data = { #NEWLINE# #INDENT# 'form-TOTAL_FORMS' : '2' , #NEWLINE# 'form-INITIAL_FORMS' : '1' , #NEWLINE# 'form-MAX_NUM_FORMS' : '' , #NEWLINE# 'form-0-id' : str ( meeting . id ) , #NEWLINE# 'form-0-name' : '2nd Tuesday of the Week Meeting' , #NEWLINE# 'form-0-authors' : [ author3 . id , author1 . id , author3 . id , author4 . id ] , #NEWLINE# 'form-1-name' : '' , #NEWLINE# 'form-1-authors' : '' , #NEWLINE# 'form-1-DELETE' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# formset = AuthorMeetingFormSet ( data = data , queryset = AuthorMeeting . objects . all ( ) ) #NEWLINE# self . assertTrue ( formset . is_valid ( ) ) #NEWLINE# instances = formset . save ( commit = False ) #NEWLINE# for instance in instances : #NEWLINE# #INDENT# instance . created = date . today ( ) #NEWLINE# instance . save ( ) #NEWLINE# #UNINDENT# formset . save_m2m ( ) #NEWLINE# self . assertQuerysetEqual ( instances [ 0 ] . authors . all ( ) , [ '<Author: Charles Baudelaire>' , '<Author: John Steinbeck>' , '<Author: Paul Verlaine>' , '<Author: Walt Whitman>' ] )