POST from external site

153 views
Skip to first unread message

kkerbel

unread,
Feb 22, 2010, 12:17:39 PM2/22/10
to Django users
I'm attempting to write a listener page which will take POST variables
sent from an external payment site to verify whether payment was
successful or not. Here is the view:

def results(request):
if request.method == 'POST':
test = request.POST.get('pmt_status')
subject = 'Jensen test values'
message = test + "\n"
emailto = 'm...@fake.com' <--normally my real address
try:
mail = EmailMessage(subject, message, 'DO_NOT...@fake.com',
[emailto])
mail.send()
return render_to_response('forms/jensen/thanks.html', {'message':
'Sent email to %s'%emailto})
except:
return render_to_response('forms/jensen/emailerror.html')
else:
return render_to_response('forms/jensen/error.html')


No matter what I do the else block is always processed. It never
detects the POST method from the external site. When I do this from
internal...it works great...not so with the external site. Is there
something special about processing POST from an external site?

kkerbel

unread,
Feb 22, 2010, 12:27:08 PM2/22/10
to Django users
Let me further clarify...when I post using django it works as
expected, meaning I have another view that which processes a new form
I submit from django. I wrote a standalone html form on my desktop
and tried submitting to the view and it still does not work.

On Feb 22, 11:17 am, kkerbel <kker...@gmail.com> wrote:
> I'm attempting to write a listener page which will take POST variables
> sent from an external payment site to verify whether payment was
> successful or not.  Here is the view:
>
> def results(request):
>         if request.method == 'POST':
>                 test = request.POST.get('pmt_status')
>                 subject = 'Jensen test values'
>                 message = test + "\n"

>                 emailto = '...@fake.com'  <--normally my real address
>                 try:
>                         mail = EmailMessage(subject, message, 'DO_NOT_RE...@fake.com',

Tim Shaffer

unread,
Feb 22, 2010, 1:53:06 PM2/22/10
to Django users
What does the HTML for the Django-generated form look like?

What does the HTML for the non-Django-generated form look like?

Are you using Django Cross Site Request Forgery protection?

Reply all
Reply to author
Forward
0 new messages