[Fixed]-Django – method PUT – Forbidden (CSRF cookie not set.):

1👍

Make sure that if you are submitting a form you {%csrf_token%} as a hidden input in your form.

Also, check to make sure that CsrfViewMiddleware is in your MIDDLEWARE_CLASSES in settings.py

0👍

If this view is not for a form but to be accessed directly by something you can remove csrf checks with csrf_exempt decorator :

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^test/src/(\d+)', csrf_exempt(MyView.as_view()), name='put_'),
]

Leave a comment