Using django with postman {“detail”:“CSRF Failed: CSRF token missing or incorrect.”}

前端 未结 7 2293
谎友^
谎友^ 2021-02-20 17:08

I\'m using postman to check json response from my django-rest-framework.

When my first try to post id, email, password through POST method to my django on AWS(amazon web

7条回答
  •  忘了有多久
    2021-02-20 17:19

    You can either use csrfmiddlewaretoken: csrf_token, in your json data where csrf_token is a valid token, but in a situation where including it you are unable to provide a correct token, comment or remove SessionAuthentication as below.

    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.TokenAuthentication',
        # 'rest_framework.authentication.SessionAuthentication',
    ]
    

提交回复
热议问题