middleware.py
from django.utils.deprecation import MiddlewareMixin
class CloseCsrfMiddleware(MiddlewareMixin):
def process_request(self, request):
print('csrf')
request.csrf_processing_done = True # csrf处理完毕
将该文件插入settings.py