[Solved]-Django: Giving validation error feedback on a form after a post redirect get


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 ("/")
    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.

Leave a comment