Django-forms Not Rendering Errors
I'm having issues rendering errors in my form, when the form is invalid, it just reloads the page and the errors don't show. I want to show the errors, like showing a text saying t
Solution 1:
Bug is on this line
return render(request, 'info/contact_us.html', {
'form': form_class,
})
When GET method is called it loads the Empty form that is form=form_class(), on POST method it should be form=form_class(request.POST). As per the above code, it is again loading fresh form
Add your return statement inside your POST block also
return render(request, 'info/contact_us.html', {
'form': form_class(request.POST),
})
or
return render(request, 'info/contact_us.html', {
'form': form,
})
Post a Comment for "Django-forms Not Rendering Errors"