You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def paragraph(request):
form1 = PSummaryForm1()
form2 = PSummaryForm2()
# return render(request, 'paragraph.html', {'form1': form1, 'form2': form2 })
# if this is a POST request we need to process the form data
if request.method == 'POST':
form1 = PSummaryForm1(request.POST)
if request.POST.get("form_type") == 'formOne':
# create a form instance and populate it with data from the request:
form1 = PSummaryForm1(request.POST)
print("paragraph1")
print("form1 content")
print(form1)
if form1.is_valid():
# process the data in form.cleaned_data as required
paragraph = form1.cleaned_data['paragraph'].strip()
length = form1.cleaned_data['length']
if length < 0:
length = 10
# paragraph_summary1 = retrieve_input(paragraph, length)
paragraph_summary1 = "this is summary paragraph1"
return render(request, "paragraph.html", {'paragraph_summary1':paragraph_summary1, 'form1': form1, 'form2': form2})
# return render(request, 'paragraph.html')
if request.POST.get("form_type") == 'formTwo':
# create a form instance and populate it with data from the request:
form2 = PSummaryForm2(request.POST)
print("paragraph2")
print("form2 contents")
print(form2)
if form2.is_valid():
# process the data in form.cleaned_data as required
paragraph = form2.cleaned_data['paragraph'].strip()
length = form2.cleaned_data['length']
if length < 0:
length = 10
# paragraph_summary2 = retrieve_input(paragraph, length)
paragraph_summary2 = "this is summary paragraph2"
return render(request, "paragraph.html", {'paragraph_summary2':paragraph_summary2, 'form1': form1, 'form2': form2})
else:
print("inside main else")
form = PSummaryForm1()
return render(request, 'paragraph.html', {'form1': form1, 'form2': form2 })