Thursday, June 26, 2014

Re: one form, many submits

From your code:
"""
if request.method=='GET':
if request.POST.get('accept'):
bid = QuotedItem.objects.get(id=2)
return render(request, 'bills/p_bill.html', {'bid' : bid})
"""

if the method is "GET", you will never have any POST parameters.
If you want POST parameter you have to send an HTTP-POST request, but
then of course the first condition will never be true. So this code
will not work.

2014-06-26 12:53 GMT+02:00 Gunpreet Ahuja <gunpreetahuja0528@gmail.com>:
>
>
> On Tuesday, June 24, 2014 11:21:23 PM UTC+5:30, Gunpreet Ahuja wrote:
>>
>>
>>
>> On Saturday, February 20, 2010 9:07:57 PM UTC+5:30, David De La Harpe
>> Golden wrote:
>>>
>>> On Sat, Feb 20, 2010 at 06:42:11AM -0800, Tom wrote:
>>
>>
>>>
>>> Check request.POST.get('cancel') to see if cancel was clicked,
>>> and request.POST.get('accept') to see if accept was clicked
>
>
> I tried this, the else part works, but the interpreter never considers the
> above condition true and the control never transfers inside the if clause!
> Please help!
> Here is my views.py:
> https://gist.github.com/GunpreetAhuja/cd5093b4e3cbf594b584
>
> --
> 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 django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/324c5116-9030-4afb-8039-ba5f24b7d3fb%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAL2Rd%3DKed8hUAXVgznMF9bXxEwMLQFu_iktCYFo2E2ikN4S7%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment