Render html content stay on current page with form action set to different url in Django
My question is there is a way to render html content(bootstrap alert) on the current page(1st page) with POST action set to a different url(2nd page)?
I have following content in views.py:
def calendar(req): # 1st page
return render(req,'calendar.html')
def result(req): # 2nd page
if req.method == 'POST':
xxx
else:
no_data = "xxx"
context = { 'no_data': no_data }
return render(req, 'calendar.html', context)
xxx
return render(req,'result.html',context)
The form info is submitted to different url(2nd page) in calendar.html:
{% if no_data %}
<div class="alert alert-warning" role="alert">
{{ no_data }}
</div>
<form action="{% url 'result' %}" method="POST">
Thank you.