AI智能
改变未来

ImportError: cannot import name ‘login‘ from ‘django.contrib.auth.views‘

原代码:

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\'),]
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » ImportError: cannot import name ‘login‘ from ‘django.contrib.auth.views‘