1if request.method == 'POST':
2 form1 = Form1( request.POST,prefix="form1")
3 form2 = Form2( request.POST,prefix="form2")
4
5 if form1.is_valid():
6 # save them
7
8 # context['form1_message'] = 'Form1 saved'
9 else:
10 #save them into context
11 context['form1']= form1
12
13 if form2.is_valid():
14 # save them
15 # context['form2_message'] = 'Form2 saved'
16 else:
17 #save them into context
18 context['form2']= form2
19
20 if form1.is_valid() and form2.is_valid():
21 #that's mean both form is valid and saved successfully
22 return redirect('page')
23 else:
24 return render('/page', context)
25
26
27else:
28 form1 = Form1(prefix="form1")
29 form2 = Form2(prefix="form2")
30