1、错误描述

2、错误原因
由于django框架的settings.py配置了中间件,为了防止跨站请求伪造,form表单POST方式会导致出现报错
"""
Django settings for amnd project.
Generated by 'django-admin startproject' using Django 2.2.7.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'a-%0lbq27@9kt5croh_1i@ra+h91h33&87@

本文介绍了在使用Django框架时遇到的CSRF cookie not set错误,详细解析了错误的原因,即settings.py中防跨站请求伪造的中间件配置。并提出了将'django.middleware.csrf.CsrfViewMiddleware'注释掉作为临时解决办法。
2355

被折叠的 条评论
为什么被折叠?



