Django Post request erro

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Django Post request erro

Ruturaj Singare
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.  

I am your regular subscriber on youtube 
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="/paid" 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="/home" 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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEhU20eLZt-%2B4u-kntwUzLL%3DO2vBbYXZ1FthB5Jn90Pb7wOT3Q%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Django Post request erro

Jani Tiainen
Hi.

Could you describe exactly in both cases:
What do you expect to happen? What does actually happen!

Also instead of using hardcoded urls you should always use {% url %} tag to form urls in templates.

pe 13. syysk. 2019 klo 16.53 Ruturaj Singare <[hidden email]> kirjoitti:
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.  

I am your regular subscriber on youtube 
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="/paid" 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="/home" 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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEhU20eLZt-%2B4u-kntwUzLL%3DO2vBbYXZ1FthB5Jn90Pb7wOT3Q%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHn91ocXQ-%3D3q%3D-x9gLVAbg%3Dkv%3DbA7zKPFA9RrJzpb_BHvtkug%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Django Post request erro

Nelson Varela
In reply to this post by Ruturaj Singare
You have to close your first form.....

So put </form> somewhere before the second form

Op vrijdag 13 september 2019 15:53:48 UTC+2 schreef Ruturaj Singare:
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.  

I am your regular subscriber on youtube 
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="/paid" 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="/home" 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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9052b0d8-576b-48f6-bf22-3d657316c762%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Django Post request error

Ruturaj Singare
Thank you for your response 
It works for me.
I have forgeted to close form tag.
Thank you so much.

Thanks & Regards
Ruturaj

On Fri, 13 Sep, 2019, 8:14 PM Nelson Varela, <[hidden email]> wrote:
You have to close your first form.....

So put </form> somewhere before the second form

Op vrijdag 13 september 2019 15:53:48 UTC+2 schreef Ruturaj Singare:
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.  

I am your regular subscriber on youtube 
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="/paid" 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="/home" 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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9052b0d8-576b-48f6-bf22-3d657316c762%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEhU20f1wnC_0JxwWCEt%3Dg%3DqTLGBcLmdnsFg3JjUn2ZP9LMt8Q%40mail.gmail.com.