Skip to main content

AdminPasswordChangeForm

A form used to change the password of a user in the admin interface.

Attributes

AttributeTypeDescription
required_css_classstring = "required"The CSS class applied to the HTML elements of required form fields, defaulting to "required".
usable_password_help_textstringHelp text displayed to administrators explaining that disabling the usable password will result in the loss of the user's current password.

Constructor

Signature

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

Parameters

NameTypeDescription
userUser objectThe user instance whose password is being changed.
*argstupleVariable length argument list.
**kwargsdictArbitrary keyword arguments.

Methods


clean()

@classmethod
def clean() - > dict

Validates the provided passwords against general security rules and user-specific constraints before returning the cleaned data.

Returns

TypeDescription
dictA dictionary of validated form input values.

save()

@classmethod
def save(
commit: boolean = True
) - > [User](../models/user.md?sid=django_contrib_auth_models_user)

Save the new password.

Parameters

NameTypeDescription
commitboolean = TrueDetermines whether the password change should be persisted to the database immediately.

Returns

TypeDescription
[User](../models/user.md?sid=django_contrib_auth_models_user)The user object with the updated password applied.

changed_data()

@classmethod
def changed_data() - > list

Identifies if the password fields have been modified, returning a simplified list of changed field names.

Returns

TypeDescription
listA list containing the string 'password' if any password-related fields were modified, otherwise an empty list.