Django html form post request error

13 views
Skip to first unread message

Ruturaj Singare

unread,
Sep 13, 2019, 9:54:11 AM9/13/19
to Django users
Hi Everyone I got one problem I have 2 form in index.html but having its own url pattern but both forms redirects to on e url using post request can you please help me.  

Both are forms are going to redirect on same url that is /home why second form are not going to on /paid
I didn't understand. Please help


My url patterns :


urlpatterns = [
path('admin/', admin.site.urls),
path('', views.index, name='index'),
path('home', views.index, name='index'),
path('paid', views.paid, name='paid')
]

My index.html form section
 <div class="col-8">
<form action="/home" method="post">
{% csrf_token %}
<input type="text" name="OrderNo" id="MyTextId" >
<input type="submit" value="Show Order" class="btn btn-danger">

<table class="table table-striped">
<thead>
<tr>
<th scope="col">Sr. No</th>
<th scope="col">Menu Items</th>
<th scope="col">Quantity
</tr>
</thead>
<tbody>
{% for order in orderList %}
<tr>
<th>{{ forloop.counter }}</th>
<td>{{ order.MenuItem }}</td>
<td>{{ order.Qty }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<form action="/paid" method="post">
{% csrf_token %}
<input type="text" name="OrderNo" id="MyId">
<input type="submit" value="Pay" class="btn btn-danger">
</form>
</div>



</div>
I think all ok but not working

Nelson Varela

unread,
Sep 13, 2019, 10:43:06 AM9/13/19
to Django users
You have to close your first form.....

So put </form> somewhere before the second form

Op vrijdag 13 september 2019 15:54:11 UTC+2 schreef Ruturaj Singare:
Reply all
Reply to author
Forward
0 new messages