练习django 访问url报错Forbidden (CSRF cookie not set.)

解决方法是把setting中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 访问url报错Forbidden (CSRF cookie not set.))