原代码:
from django.conf.urls import urlfrom django.contrib.auth.views import loginfrom . import viewsurlpatterns = [# 登录页面url(\'login/\', login, {\'template_name\': \'users/login.html\'}, name=\'login\'),]
报错:ImportError: cannot import name ‘login’ from ‘django.contrib.auth.views’
修改如下:
from django.conf.urls import urlfrom django.contrib.auth.views import LoginViewfrom . import viewsurlpatterns = [# 登录页面url(\'login/\', LoginView.as_view(template_name=\'users/login.html\'), name=\'login\'),]