Re: Hi all, i'm using 2 modelforms in one view function one as foreign key but when i submit babyform2 not storing in database. anyone please fix this

2021-06-01 Thread Lalit Suthar
because you're passing commit=False with form2 On Tue, 1 Jun 2021 at 14:10, Hugh Frost wrote: > def detail(request): > if request.method == 'POST': > baby_form1 = BabyForm1(data=request.POST) > baby_form2 = BabyForm2(data=request.POST) > > if baby_form1.is_valid() and

Hi all, i'm using 2 modelforms in one view function one as foreign key but when i submit babyform2 not storing in database. anyone please fix this

2021-06-01 Thread Hugh Frost
def detail(request): if request.method == 'POST': baby_form1 = BabyForm1(data=request.POST) baby_form2 = BabyForm2(data=request.POST) if baby_form1.is_valid() and baby_form2.is_valid(): baby_form1.save() print(baby_form1) baby_form2.b