Below is the view
def TestPageView(request):
if request.method == 'POST':
contactform = ContactForm(request.POST,prefix="contact")
subscriptionform = SubscriptionForm(request.POST,prefix="subscription")
suggestionform = SuggestionForm(request.POST,prefix="suggestion")
globalmessageform = GlobalMessageForm(request.POST,prefix="globalmessage")
if contactform.is_valid() and subscriptionform.is_valid() and suggestionform.is_valid() and globalmessageform.is_valid():
contact = contactform.save()
subscription = subscriptionform.save()
suggestion = suggestionform.save()
globalmessage = globalmessageform.save()
else:
print(form.errors)
else:
contactform = ContactForm(prefix="contact")
subscriptionform = SubscriptionForm(prefix="subscription")
suggestionform = SuggestionForm(prefix="suggestion")
globalmessageform = GlobalMessageForm(prefix="globalmessage")
return render(request,'dashboard/test_page.html',{'contactform':contactform,'subscriptionform':subscriptionform,'suggestionform':suggestionform,'globalmessageform':globalmessageform})
How to write html code to show and save these forms on test_page.html.I know how to show one form but there are 4 forms in this case.
I have coded like this but i cannot see any output on test_page.html. Page is completely blank.
{% extends "base.html" %}
{% block content %}
{% load static %}
<div>
<div>
<form method="post" >
{% csrf_token %}
{{ contactform.as_p }}
</form>
</div>
<div>
<form method="post" >
{% csrf_token %}
{{ subscriptionform.as_p }}
</form>
</div>
<div>
<form method="post" >
{% csrf_token %}
{{ suggestionform.as_p }}
</form>
</div>
<div>
<form method="post" >
{% csrf_token %}
{{ globalmessageform.as_p }}
</form>
</div>
<input type="submit" name="Save">
</div>
{% endblock %}