[英]“AttributeError: module 'django.contrib.auth.views' has no attribute 'password_reset' ” error in urls.py
I am using Django 3.0.5 and python 3.6 and getting the error from the terminal as:我正在使用 Django 3.0.5 和 python 3.6 并从终端获取错误:
" AttributeError: module 'django.contrib.auth.views' has no attribute 'password_reset' " in my urls.py file. “ AttributeError: module 'django.contrib.auth.views' has no attribute 'password_reset'” 在我的 urls.py 文件中。
urls.py网址.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.我在这里检查过,它谈论的是我写的相同的 4 个视图,然后为什么会出现错误。 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".
当我在“url('password-reset/',auth_views.password_reset, name='password_reset')”中将“auth_views.password_reset”更改为“auth_views.PasswordResetForm”时,终端没有显示“password_reset”的任何错误,但随后它显示“password_reset_done”错误。
Can anyone please tell why I am getting this error and how to fix it.谁能告诉我为什么会收到此错误以及如何解决它。 Any help would be appreciated.
任何帮助,将不胜感激。
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'), ]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.