Django rest framework - Authentication error with PUT requests

前端 未结 3 687
迷失自我
迷失自我 2021-02-11 03:44

I have a very simple Resource like this for my model \'Presentacion\'

class PresentacionResource(ModelResource):
    m         


        
3条回答
  •  [愿得一人]
    2021-02-11 04:28

    If you are using Django's session based authentication, then you may be tripping over the CSRF protection built into Django (see UserLoggedInAuthentication class[1]).

    If this is the case, you will need to ensure that a CSRF cookie gets sent to the client and then you can adapt the jQuery instructions[2] to send the X-CSRFToken header with requests that may change data.

    [1] http://django-rest-framework.org/_modules/authentication.html

    [2] https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax

提交回复
热议问题