app下创建 csrf_disable.py
在该文件中:
from rest_framework.authentication import SessionAuthentication视图中的SessionAuthentication用CsrfExemptSessionAuthentication代替
class CsrfExemptSessionAuthentication(SessionAuthentication):
def enforce_csrf(self, request):
return