Which HttpResponse method will help me do this ? I have a form validation code in some view :
if request.method == 'POST'
form = SomeForm(request.POST)
if form.is_valid():
form.save()
else:
return HttpResponseRedirect('back.to.this.view')
# I want to redirect to the same form page with a small error message
#below the form saying "This is an empty form"
How do I add that message in the page ?
I am new to Django and web development
This would be a strange thing to do.
You don’t want to redirect back to the current view. What you want to do is redisplay the existing page, with the errors automatically generated by your call to
form.is_valid(). You do this by following the example view in the documentation.