错误原因
由于django框架的settings.py配置了中间件,为了防止跨站请求伪造,form表单POST方式会导致出现报错
解决办法:
将'django.middleware.csrf.CsrfViewMiddleware'注释
MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', # 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ]
参考连接:
https://blog.csdn.net/you23hai45/article/details/107931579