Django Def Form_valid With Two Forms
I'd like to use two forms into the same views. It is a restricted channel. The first forms is a chat and the second one launch the conversation (boolean fiels with default = false)
Solution 1:
You can do it by adding a name to identify the submit button of the form submitted.
So your markup would look something along the lines of;
<formaction=""method="post">
{{ form_1 }}
<inputtype="submit"name="form_1"value="Submit" /></form><formaction=""method="post">
{{ form_2 }}
<inputtype="submit"name="form_2"value="Submit" /></form>
Then you can figure out which form was submitted in the post
method;
defpost(self, *args, **kwargs):
if'form_1'in request.POST:
process_form_1()
elif'form_2'in request.POST:
process_form_2()
Post a Comment for "Django Def Form_valid With Two Forms"