1. ajax发送请求的代码如下:

    image.png

  2. django框架的代码如下(关键是引入红框的库文件):

    image.png

  3. 参考链接:

  官网:https://docs.djangoproject.com/en/dev/ref/csrf/#ajax