Python Django提交表单时报错:Forbidden (403) CSRF verification failed. Request aborted.

报错截图:
Python Django提交表单时报错:Forbidden (403) CSRF verification failed. Request aborted._第1张图片

解决方法:
把settings里面一个叫csrf的安全机制的注释掉即可。

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',
]

你可能感兴趣的:(Django,python,django,csrf)