[Answer]-The view blog.views.contacto didn't return an HttpResponse object

1👍

✅

Your view doesn’t return an HttpResponse if request.method is not POST.

There is an indentation issue. You need to return an unbound form in case the form is not submitted:

def contacto (request):
    if request.method == 'POST': #Si e formulario es enviado...
        form = Formulario(request.POST)
        if form.is_valid(): #Si son validos los datos del formulario
            return HttpResponseRedirect('/blog/gracias') #redireccion a gracias
    else:  # <-- WATCH WHERE ELSE IS
        form = Formulario() #un Unbound form

    return render(request, 'contacto.html',{'form':form,})

Also see this relevant example that describes this standard form view pattern.

Leave a comment