ImportError: cannot import name 'login' from 'django.contrib.auth.views'
when I runserver,I take the error ImportError: cannot import name 'login' from 'django.contrib.auth.views' .why?
same problem, any solution?
same problem, any solution?
same probleme
xadmin don't work with django 2.1.0 but it's work with django 2.0.7
It is located in django.contrib.auth (cut out the .views). It seems to have been moved in 2.1...
Can't find 'password_reset' though!
These are deprecated with 2.1 in favour of class based views. see https://docs.djangoproject.com/en/2.1/internals/deprecation/ and https://docs.djangoproject.com/en/2.1/releases/1.11/#deprecated-features-1-11
Same problem, fixed as Craig said and I'm trying to find password_reset too
nicogaspa, from the links I posted
contrib.auth’s password_change(), password_change_done(), password_reset(), password_reset_done(), password_reset_confirm(), and password_reset_complete() function-based views are deprecated in favor of new class-based views PasswordChangeView, PasswordChangeDoneView, PasswordResetView, PasswordResetDoneView, PasswordResetConfirmView, and PasswordResetCompleteView.
`from django.conf.urls import url from django.contrib.auth.views import login
from . import views
urlpatterns = [ # 登录页面 url(r'^login/$', login, {'template_name': 'users/login.html'}, name='login'), ]` This is my urls.py . As you expect, it will go wrong. I found many ways, but they didn't work. One way is that removing .views, but it also didn't work. And report errors:TypeError: login() got an unexpected keyword argument 'template_name' Because I just start learning Django, it's difficult for me to understand the Official documents. It would be better if you could tell me how to solve this problem.Thanks
Anthony - this is my urls.py for my "accounts" app.
` from django.conf.urls import url
from django.contrib.auth.views import ( PasswordResetView, PasswordResetConfirmView, PasswordResetDoneView, PasswordResetCompleteView, PasswordChangeView, PasswordChangeDoneView, )
from accounts import views from accounts.views import ssl_required # decorator for contrib.auth functions
urlpatterns = (
url(r"^login", views.LoginView.as_view(), name="login"),
url(r"^logout", views.LogOutView.as_view(), name="logout"),
url(
r"^registered",
views.RegisteredView.as_view(),
name="accounts-registered",
),
url(r"^register", views.RegisterView.as_view(), name="accounts-register"),
url(
r"^my-account/(?P
@rowinggolfer Thank you very much. I solved this problem through your codes just now.
`from django.conf.urls import url from django.contrib.auth.views import login
from . import views
urlpatterns = [
登录页面
url(r'^login/$', login, {'template_name': 'users/login.html'}, name='login'), ]` This is my urls.py . As you expect, it will go wrong. I found many ways, but they didn't work. One way is that removing .views, but it also didn't work. And report errors:TypeError: login() got an unexpected keyword argument 'template_name' Because I just start learning Django, it's difficult for me to understand the Official documents. It would be better if you could tell me how to solve this problem.Thanks
我也遇到了类似的问题
It is located in django.contrib.auth (cut out the .views). It seems to have been moved in 2.1...
Can't find 'password_reset' though!
It worked thank you
The following code also works (you need to import LoginView instead of login)...
from django.urls import path from django.contrib.auth.views import LoginView
app_name = 'users' urlpatterns = [ # Login page path('login/', LoginView.as_view(template_name='users/login.html'), name='login') ]