I am learning django forms right now. I can not see the output of the error in the website as a text message, it only shows as a pop-up message with the default error message even though I set my own error message. Also, my console is not printing anything after
if form.is_valid():
This is my views.py file:
def forms(request):
if request.method == 'POST':
form = Forms(request.POST)
if form.is_valid():
print("hello")
form.save()
print(form.cleaned_data)
return HttpResponseRedirect('/thank_you')
else:
form = Forms()
return render(request, "form/index.html", {
'form': form
})
def thank_you(request):
return render(request, 'form/thankyou.html')
And here's the html file
<html lang='en'>
<head>
<meta charset="UTF-8">
</head>
<body>
<form action="/thank-you" method="POST">
{% csrf_token %}
{{ form.name.label_tag}} <br>
{{form.name}} <br>
{{form.name.errors}}
<button type="submit">Send</button>
</form>
novalidateattribute to your form tag:<form action="/thank-you" method="POST" novalidate>does that do what you expect?