def contactview(request): form = ContactForm() if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): form.save(commit = True) print('details saved successfully') return render(request, 'testapp/thanks.html') return render(request, 'testapp/contact.html', {'form':form})
def contact_view(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): form.save() form = ContactForm() return render(request, 'contact.html', {'form': form}) else: return HttpResponse('<h1> Invalid Form</h1>') else: form = ContactForm() return render(request, 'contact.html', {'form': form})