gpt4 book ai didi

python - 尝试自定义 Django SetPasswordForm

转载 作者:太空宇宙 更新时间:2023-11-03 13:58:21 26 4
gpt4 key购买 nike

我试图覆盖 SetPasswordForm 以添加占位符和类,但似乎不起作用。我成功地为登录页面和密码重置页面做到了这一点,但在这里我陷入了困境。

class MySetPasswordForm(SetPasswordForm):
new_password1 = forms.CharField(
label=_("New password"),
widget=forms.PasswordInput(attrs={'placeholder': 'New Password', 'class': 'password1'}),
strip=False,
help_text=password_validation.password_validators_help_text_html(),
)
new_password2 = forms.CharField(
label=_("New password confirmation"),
strip=False,
widget=forms.PasswordInput(attrs={'placeholder': 'Repeat Password', 'class': 'password2'}),
)
urlpatterns = [  path('accounts/password_reset/', auth_views.PasswordResetView.as_view(
form_class=MyPasswordResetForm)),
path('accounts/password_reset_confirm/', auth_views.PasswordResetConfirmView.as_view(
form_class=MySetPasswordForm)),
path('accounts/', include('django.contrib.auth.urls')),]

这准确吗?

最佳答案

您在 URL 模式中使用了错误的路径。应该是:

'reset/<uidb64>/<token>/'

关于python - 尝试自定义 Django SetPasswordForm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49434711/

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