Handling Multiple Forms On The Same Page In Django Without Django's Default Model Form
I am trying to develop a webpage with two forms on the same page with Django. Anyone will able to fillup any single form and submit it, then that data will be saved in the database
Solution 1:
You can do that by setting different form action and by making different view for perticular form like this
inside your template :
<formmethod="POST"action="{% url 'form1' %}">
........all input fields
</form><formmethod="POST"action="{% url 'form2' %}">
........all input fields
</form>
inside your views.py :
defform1(request):
if request.method == "POST":
...get all values
return render(request,'forms.html')
defform2(request):
if request.method == "POST":
...get all values
return render(request,'forms.html')
Post a Comment for "Handling Multiple Forms On The Same Page In Django Without Django's Default Model Form"