Django rest framework API, web request prompt 403 error

  1. you can get data normally by using postman request.
  2. request using web page with error message:

{"detail": "CSRF Failed: CSRF cookie not set."}

how to solve this?


first check in the browser to see if there is a csrftoken cookie,. If not, you need to see why the cookie is not set, such as whether the django.middleware.csrf.CsrfViewMiddleware is deleted in the MIDDLEWARE.

Menu