Django offers an simple and fast option for "Forget password" by overriding the default templates.
Some of these forms come with help text
The password_reset_confirm which I get the reset link from the email, I don't know how to get rid of the help text messages.
It is displayed in the password_reset_confirm.html, by using {{ form.as_p}}
Is there any way to remove the help text, without extending the ResetPasswordForm in forms.py to set the help text to none.
It's complicated as the url for this form takes token.
I tried this, but I'm almost sure it wouldn't work.
forms.py
class ResetPassword(PasswordResetForm):
class Meta:
fields = ("new_password1", "new_password2")
model = get_user_model()
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["new_password1"].help_text = None
views.py
class resetpassword(LoginRequiredMixin, generic.UpdateView):
template_name = "registration/password_change_form.html"
success_url = reverse_lazy('password_reset_complete')
form_class = forms.ResetPassword
def get_object(self, queryset=None):
return self.request.user
def get_form_kwargs(self):
kwargs = super(resetpassword, self).get_form_kwargs()
kwargs['user'] = kwargs.pop('instance')
return kwargs