BaseUserCreationForm
A form that creates a user, with no privileges, from the given username and password.
Attributes
| Attribute | Type | Description |
|---|---|---|
| password1 | forms.CharField | The primary password input field used for setting the user's initial password. |
| password2 | forms.CharField | The confirmation password input field used to verify the primary password entry matches. |
Constructor
Signature
def BaseUserCreationForm(
*args: any,
**kwargs: any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| *args | any | Variable length argument list passed to the parent constructor. |
| **kwargs | any | Arbitrary 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
| Type | Description |
|---|---|
dict | A 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
| Name | Type | Description |
|---|---|---|
| commit | boolean = True | A flag indicating whether the user instance should be immediately persisted to the database or returned without saving. |
Returns
| Type | Description |
|---|---|
[User](../models/user.md?sid=django_contrib_auth_models_user) | The created user instance with the hashed password applied. |