2👍
What you are doing wrong is passing the form to context with post values that you get once.You just need to call the form before context. This way every time it will show you empty form after saving the result.
if Cform.is_valid() and Pform.is_valid() :
Cform.save()
Pform.save()
Cform = ChildForm()
Pform = ParentForm()
context = {
"Cform" : Cform,
"Pform" : Pform,
}
1👍
It is customary to use Post/Redirect/Get for form submissions. What you are missing is a redirect after the successful validation of the submitted form values:
if Cform.is_valid() and Pform.is_valid() :
Cform.save()
Pform.save()
return redirect('/formulaire') # <- This.
👤Flux
- [Django]-Same origin Issue with iframe loaded from AWS S3
- [Django]-Django 3rd Party Auth Systems
- [Django]-Django template inheritance – views.py for multiple child templates
Source:stackexchange.com