1π
β
The main thing I see that looks odd is that your HTML form
tag has "/peoples/"
as its action, but that URL is not bound to your form processing view in the code we see here. I mostly use action=""
in my forms, so that it submits to the same URL that rendered the view.
Secondly, when you redefine your python variable form
in your view:
if request.POST:
form = PeopleForm(request.POST)
You have already assigned the old form
to the context, and do not reassign it. So if your form is not valid, you wonβt see the errors or submitted values.
This is of course irrelevant if your form action is wrong such that the view is not called with the POST
data.
π€Peter DeGlopper
Source:stackexchange.com