Skip to main content

SetPasswordForm

A form that lets a user set their password without entering the old password

Attributes

AttributeTypeDescription
new_password1forms.CharFieldForm field for the user to enter their desired new password, labeled as 'New password'.
new_password2forms.CharFieldForm field for the user to re-enter their new password for confirmation purposes, labeled as 'New password confirmation'.
userUser model instanceThe user instance whose password will be updated upon successful form submission.

Constructor

Signature

def SetPasswordForm(
user: object,
*args: tuple,
**kwargs: dict
) - > null

Parameters

NameTypeDescription
userobjectThe user object for whom the password is being set.
*argstupleVariable length argument list for the parent form class.
**kwargsdictArbitrary keyword arguments for the parent form class.

Signature

def SetPasswordForm(
user: User object,
*args: tuple,
**kwargs: dict
)

Parameters

NameTypeDescription
userUser objectThe user instance for whom the new password is being set
*argstuplePositional arguments passed to the parent Form class
**kwargsdictKeyword 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

TypeDescription
dictA 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

NameTypeDescription
commitboolean = TrueDetermines whether the user object should be immediately persisted to the database

Returns

TypeDescription
User objectThe user instance with the updated password applied