gpt4 book ai didi

python - 如何在 password_reset_complete Django 中重定向登录链接

转载 作者:太空宇宙 更新时间:2023-11-04 04:11:00 25 4
gpt4 key购买 nike

password_reset_complete 中的登录链接将用户定向到帐户/登录而不是帐户/登录。我该如何解决这个问题?

错误:

Using the URLconf defined in tutorial.urls, Django tried these URL patterns, in this order:
[name='login_redirect']
admin/
account/
The current path, accounts/login/, didn't match any of these.

账户/urls.py:

urlpatterns = [

path('', views.home, name="home"),
path('login/', LoginView.as_view(template_name='accounts/login.html'), name='login'),
path('logout/', LogoutView.as_view(template_name='accounts/logout.html'), name='logout'),
path('register/', views.register, name='register'),
path('profile/', views.view_profile, name='profile'),
path('profile/edit/', views.edit_profile, name='profile-edit'),
path('change-password/', views.change_password, name='change-password'),
path('reset-password/', PasswordResetView.as_view(), name='reset-password'),
path('reset-password/done/', PasswordResetDoneView.as_view(), name='password_reset_done'),
path('reset-password/confirm/<uidb64>/<token>/',
PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
path('reset-password/complete/', PasswordResetCompleteView.as_view(), name='password_reset_complete'),

主/urls.py:

urlpatterns = [
path(r'', views.login_redirect, name='login_redirect'),
path('admin/', admin.site.urls),
path('account/', include('accounts.urls')),

]

设置.py:

LOGIN_REDIRECT_URL = '/account/'

谢谢

最佳答案

似乎您定义了错误的 url 模式

urlpatterns = [
path(r'', views.login_redirect, name='login_redirect'),
path('admin/', admin.site.urls),
<b>path('accounts/', include('accounts.urls')), # use "accounts" instead of "account"</b>
]

注意事项

现在开始,您所有的 /account/.. 网址将更改为 /accounts/...

关于python - 如何在 password_reset_complete Django 中重定向登录链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56276451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com