Question:I have a view that contains two Django forms. They were previously working but now whichever one is underneath the top one does not work. I have tried switching the order of the forms and whichever form is on the top will work while the other one will not do anything when submitted.
I tried changing my forms so they resemble this example
if request.method == "POST" and "selectgenderform" in request.POST:but that did not work (the forms did nothing).
Does anyone know how to fix this problem?
part of views.py
Answer:You have a flow problem. If the user submits a comment, then your bid_form is invalid, and so it goes to the ‘else’ section of the if bid_form.is_invalid(), which redirects to another page before the comment form is tested. Thankfully they both have the same else statement, so you can use elif rather than two else…ifs
Assuming only one form can be submitted at a time, try the following:
If you have better answer, please add a comment about this, thank you!