[Answered ]-Why do I get this valueerror when I try to validate my from via recaptcha?

1👍

You don’t return a response when your form.is_valid() is False.
Try adding this:

def home(request):
    if request.method == 'POST':
        form = PostForm(request.POST or None)

        if form.is_valid():
            save_it = form.save(commit=False)
            save_it.save()
            return HttpResponseRedirect(reverse(view, args=(save_it.pk,)))
        else:
            return render(request, "home.html", locals())  # new line
    else:
        form = PostForm(request.POST or None)
        return render(request, "home.html", locals())

1👍

Right after I clicked send the solution occurred to me. I just needed to return the render of home.html in case the form is not valid. Sorry for the unnecessary post!

Leave a comment