django Forbidden

时间:2022-08-02 07:22:46

Forbidden (CSRF cookie not set.)解决方法

Forbidden (CSRF cookie not set.):xxx解决方法:在django项目的settings.py文件中,找到MIDDLEWARE,进行下面的修改即可

python
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
# 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]