PasswordResetView
This class provides a form-based view for initiating the password reset process by sending a recovery email to the user. It manages the configuration for email templates, subject lines, and token generation while utilizing a specialized form to validate user input and trigger the reset logic. Upon successful form submission, the view redirects users to a confirmation URL.
Attributes
| Attribute | Type | Description |
|---|---|---|
| email_template_name | string = "registration/password_reset_email.html" | The path to the template used for generating the body of the password reset email sent to the user. |
| extra_email_context | dict | A dictionary of additional context variables to be passed to the email templates during the password reset process. |
| form_class | class = PasswordResetForm | The form class used to collect the user's email address for the password reset request. |
| from_email | string | The email address used as the sender for the password reset email; if None, the DEFAULT_FROM_EMAIL setting is used. |
| html_email_template_name | string | The path to an optional HTML template used to generate a multipart HTML version of the password reset email. |
| subject_template_name | string = "registration/password_reset_subject.txt" | The path to the template used for generating the subject line of the password reset email. |
| success_url | string = reverse_lazy("password_reset_done") | The URL to redirect to after the password reset request form has been successfully submitted. |
| template_name | string = "registration/password_reset_form.html" | The path to the template used to render the password reset request form page. |
| title | string = _("Password reset") | The localized title string displayed on the password reset form page. |
| token_generator | object = default_token_generator | The instance used to generate and verify the unique security tokens included in the password reset links. |
Methods
form_valid()
@classmethod
def form_valid(
form: [PasswordResetForm](../forms/passwordresetform.md?sid=django_contrib_auth_forms_passwordresetform)
) - > [HttpResponse](../../../http/response/httpresponse.md?sid=django_http_response_httpresponse)
Triggers the password reset email delivery by saving the form with the configured email templates and security settings before redirecting to the success URL.
Parameters
| Name | Type | Description |
|---|---|---|
| form | [PasswordResetForm](../forms/passwordresetform.md?sid=django_contrib_auth_forms_passwordresetform) | The validated form instance containing the user's email address and logic for generating reset links. |
Returns
| Type | Description |
|---|---|
[HttpResponse](../../../http/response/httpresponse.md?sid=django_http_response_httpresponse) | An HTTP redirect response to the success_url defined in the view. |