Forbidden (403) CSRF verification failed. Request aborted.

{% csrf_token%},

is added to the form form of html in the

template.

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

above is the content of the root directory"s settings.py.
read other people"s blogs and add @ csrf_protect annotations to the methods in view, but they are still not correct

.
Feb.26,2021

I don't know why, but I just tried it again later

Menu