call the login method that comes with django when logging in: from django.contrib.auth import login, authenticate
user = authenticate (username=username, password=password)
login (request, user)
threw the error of "WSGIRequest" object has no attribute" session" in this sentence. I checked on the Internet and said that the name of middle in settings is wrong, but I checked that my name is right: MIDDLEWARE_CLASSES, please point out that the version I use is django2.1.1. Thank you
my classes goes like this:
MIDDLEWARE_CLASSES = (
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.auth.middleware.SessionAuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.middleware.security.SecurityMiddleware",
)