SetPasswordForm
A form that lets a user set their password without entering the old password
Attributes
| Attribute | Type | Description |
|---|---|---|
| new_password1 | forms.CharField | Form field for the user to enter their desired new password, labeled as 'New password'. |
| new_password2 | forms.CharField | Form field for the user to re-enter their new password for confirmation purposes, labeled as 'New password confirmation'. |
| user | User model instance | The user instance whose password will be updated upon successful form submission. |
Constructor
Signature
def SetPasswordForm(
user: object,
*args: tuple,
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| user | object | The user object for whom the password is being set. |
| *args | tuple | Variable length argument list for the parent form class. |
| **kwargs | dict | Arbitrary keyword arguments for the parent form class. |
Signature
def SetPasswordForm(
user: User object,
*args: tuple,
**kwargs: dict
)
Parameters
| Name | Type | Description |
|---|---|---|
| user | User object | The user instance for whom the new password is being set |
| *args | tuple | Positional arguments passed to the parent Form class |
| **kwargs | dict | Keyword arguments passed to the parent Form class |
Methods
clean()
@classmethod
def clean() - > dict
Validates that the two password fields match and ensures the new password meets the security requirements for the specific user.
Returns
| Type | Description |
|---|---|
dict | A dictionary of cleaned data after validation logic has been applied |
save()
@classmethod
def save(
commit: boolean = True
) - > User object
Updates the user's password in the database and performs the save operation if requested.
Parameters
| Name | Type | Description |
|---|---|---|
| commit | boolean = True | Determines whether the user object should be immediately persisted to the database |
Returns
| Type | Description |
|---|---|
User object | The user instance with the updated password applied |