3👍
You’re misunderstanding. You’re only supposed to redirect after a successful post. On a post that fails validation, you don’t redirect at all, you redisplay the invalid form – whichwill show the validation errors.
form = BasicForm(request.POST)
if form.is_valid()
return redirect ("/")
else:
ctx = {'form' : form}
return render(request, "template.htnl,", ctx)
Note, a FormView will handle all this for you; you shouldn’t have to define post
or get
methods at all.
Source:stackexchange.com