ivknv
ivknv

Reputation: 305

httplib - CSRF token

Here's the problem:
I've got a Django site.
I'm trying to send POST request to site with httplib.

When I try to send POST request, Django requires CSRF token.

How can I send POST request without any problems?

Upvotes: 1

Views: 255

Answers (1)

Pass the CSRF token to Django, or disable CSRF on the view handling the request.

from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse

@csrf_exempt
def my_view(request):
    return HttpResponse('Hello world')

Upvotes: 2

Related Questions