Disable CSRF verification for Django REST API

If you are also sucked by CSRF Failed message in django rest,
then there is a professional way to disable the CSRF verification while
using Django REST APIs.

Error:

{ "detail": "CSRF Failed: CSRF token missing or incorrect." }

Add following lines in your settings.py:


REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
)
}

 

or if you have already these lines in your settings.py file, then find and remove following line from settings.py:
'rest_framework.authentication.SessionAuthentication'