Skip to main content

BaseUserCreationForm

A form that creates a user, with no privileges, from the given username and password.

Attributes

AttributeTypeDescription
password1forms.CharFieldThe primary password input field used for setting the user's initial password.
password2forms.CharFieldThe confirmation password input field used to verify the primary password entry matches.

Constructor

Signature

def BaseUserCreationForm(
*args: any,
**kwargs: any
) - > null

Parameters

NameTypeDescription
*argsanyVariable length argument list passed to the parent constructor.
**kwargsanyArbitrary keyword arguments passed to the parent constructor.

Methods


clean()

@classmethod
def clean() - > dict

Validates the form data by ensuring both password fields match and meet complexity requirements before proceeding with standard model form validation.

Returns

TypeDescription
dictA dictionary of cleaned data containing the validated username and password fields.

save()

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

Saves the new user instance to the database after securely hashing the provided password.

Parameters

NameTypeDescription
commitboolean = TrueA flag indicating whether the user instance should be immediately persisted to the database or returned without saving.

Returns

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