ImportError:无法从'django.contrib.auth.views'导入名称'登录'[重复]

我的代码:

from django.conf.urls import url
from . import views
from django.contrib.auth.views import login

app_name='accounts'

urlpatterns = [
    url(r'^$', views.home , name='home'),
    url(r'^login/$' , login , {'template_name':'login.html'})

]'

错误:

ImportError:无法从“ django.contrib.auth.views”(C:\ Python \ Notes \ lib \ site- 包\ django \ contrib \ auth \ views.py)

评论
pculpa
pculpa
from django.conf.urls import url
from . import views
from django.contrib.auth.views import LoginView

app_name='accounts'

urlpatterns = [
    url(r'^$', views.home , name='home'),
    url(r'^login/$' , LoginView.as_view(template_name='login.html'))

]'
点赞
评论