Reputation: 347
I am using Django 3.0.5 and python 3.6 and getting the error from the terminal as :
" AttributeError: module 'django.contrib.auth.views' has no attribute 'password_reset' " in my urls.py file.
urls.py
```
from django.contrib import admin
from django.urls import path
from django.contrib.auth import views as auth_views
from django.conf.urls import url
from blog import views
urlpatterns = [
path('admin/', admin.site.urls),
path('index/',views.index, name='index'),
path('datetime/',views.current_datetime,name='datetime'),
path('',views.post_list,name='post_list'),
url(r'^blog/(?P<id>\d+)/(?P<slug>[\w-]+)/$',views.post_detail,name="post_detail"),
url('post_create/',views.post_create,name = "post_create"),
url('login/', views.user_login,name="user_login"),
url('logout/', views.user_logout,name="user_logout"),
#Password reset urls
url('password-reset/',auth_views.password_reset, name='password_reset'),
url('password-reset/done/',auth_views.password_reset_done,name="password_reset_done"),
url('password-reset/confirm/(?P<uidb64>[\w-]+)/(?P<token>[\w-]+)/',auth_views.password_reset_confirm, name="password_reset_confirm"),
url('password-reset/complete/', auth_views.password_reset_complete,name="password_reset_complete"),
]
```
I have checked here which is talking about the same 4 views which I have written then why I am getting the error. When I change "auth_views.password_reset" to "auth_views.PasswordResetForm in "url('password-reset/',auth_views.password_reset, name='password_reset')" then, terminal does not show any error for "password_reset" but then it shows error for "password_reset_done".
Can anyone please tell why I am getting this error and how to fix it. Any help would be appreciated.
Upvotes: 1
Views: 4618
Reputation: 381
This could help,
from django.contrib.auth import views from django.urls import path urlpatterns = [ path('login/', views.LoginView.as_view(), name='login'), path('logout/', views.LogoutView.as_view(), name='logout'), path('password_change/', views.PasswordChangeView.as_view(), name='password_change'), path('password_change/done/', views.PasswordChangeDoneView.as_view(), name='password_change_done'), path('password_reset/', views.PasswordResetView.as_view(), name='password_reset'), path('password_reset/done/', views.PasswordResetDoneView.as_view(), name='password_reset_done'), path('reset/<uidb64>/<token>/', views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'), path('reset/done/', views.PasswordResetCompleteView.as_view(), name='password_reset_complete'), ]
Upvotes: 12