i need to update the database of django server from c client (not browser), i used POST method to update ,header body contain json data, since i sont have csrf token its giving back 403 error
im using middleware to acquire this json data (using request.body
) and save to database
my http header:
"POST /post HTTP/1.1 \\r\\nHost:192.168.1.9\\r\\n\\r\\n {\\"Lupttime\\":\\"7-2-2016 17:28\\"}"
POST
Host:192.168.1.9
{"Lupttime":"7-2-2016 17:28"}
django log:
Forbidden (CSRF cookie not set.): /post
[09/Mar/2016 12:16:15] "POST /post HTTP/1.1 " 403 2629
additional doubt
You can use the decorator
@csrf_exempt
def my_view(request):
#handle request
read about it here
Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.