2👍
✅
def podcastsetup(request):
title = 'Podcast Setup'
title_align_center = True
form = PodcastSetupForm(request.POST or None)
context = {
"title": title,
"form": form
}
if form.is_valid():
instance = form.save(commit=False)
company_name = form.cleaned_data.get("company_name")
first_name = form.cleaned_data.get("first_name")
last_name = form.cleaned_data.get("last_name")
instance.company_name = company_name
instance.first_name = first_name
instance.last_name = last_name
instance.save()
return render(request, "forms.html", context)
else:
return render(request, "forms.html", context)
Try this, you need to return a response even if the form is not valid.
Source:stackexchange.com