app下創建 csrf_disable.py
在該文件中:
from rest_framework.authentication import SessionAuthentication視圖中的SessionAuthentication用 CsrfExemptSessionAuthentication代替
class CsrfExemptSessionAuthentication(SessionAuthentication):
def enforce_csrf(self, request):
return
