Django Http post and csrf error

86 views
Skip to first unread message

Tanmay Kansara

unread,
Mar 30, 2015, 5:54:14 PM3/30/15
to django...@googlegroups.com

I am trying to do the following:

1) A payment solution is supposed to send an HTTP Post to my site 
2) I would like to read the contents of the request(xml) and update my records to reflect the payment

I am trying this for the first time. When I create a URL path, and send a post to that address I get the csrf error.

Is there a way using Django wherein I can accept a post and don't have to return a response.

Thanks Tanmay

Vijay Khemlani

unread,
Mar 30, 2015, 7:58:49 PM3/30/15
to django...@googlegroups.com
To prevent the CSRF validation you can use the csrf_exempt decorator


The normal way to handle a POST request is to issue a redirect (HTTP 302) after handling the request, but if it is an automated request I guess you can return an empty response directly from the view.

--
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...@googlegroups.com.
To post to this group, send email to django...@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/e722bcd3-51e1-4fbb-a38d-6fd898317e52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anderson Resende

unread,
Mar 31, 2015, 10:11:43 AM3/31/15
to django...@googlegroups.com

In your template put  in your form:

{% csrf_token %}

example:

<form method="POST" action=".....">
  {% csrf_token %}

</form>

Reply all
Reply to author
Forward
0 new messages