Skip to main content

LoginForm

Handles user login with support for username, email, or phone-based authentication.

Fields

CharField | EmailField
Login identifier. Field type varies based on LOGIN_METHODS setting.
PasswordField
User password. Omitted if passwordless login is enabled.
BooleanField
Remember me checkbox. Omitted if SESSION_REMEMBER is configured.

Constructor Parameters

HttpRequest
The HTTP request object.

Methods

user_credentials()

Returns credentials dictionary for authentication.
dict
Dictionary with login method and password (if applicable).

login(request, redirect_url=None)

Performs the login action.
HttpRequest
The HTTP request object.
str
URL to redirect after login.
HttpResponse
Response object (redirect or stage flow).

SignupForm

Handles user registration with configurable fields.

Fields

CharField
Username field. Presence depends on SIGNUP_FIELDS setting.
EmailField
Email field. Presence and requirement depends on SIGNUP_FIELDS setting.
EmailField
Email confirmation field. Only if configured in SIGNUP_FIELDS.
PasswordField
Password field. Omitted for passkey signup.
PasswordField
Password confirmation. Only if configured in SIGNUP_FIELDS.
CharField
Phone number field. Only if configured in SIGNUP_FIELDS.

Constructor Parameters

bool
default:"False"
Whether this is a passkey-based signup.
bool
Override email field requirement.
bool
Override username field requirement.

Methods

validate_unique_email(value)

Validates email uniqueness and handles enumeration prevention.
str
Email address to validate.
str
Returns the validated email.

try_save(request)

Attempts to save the user, handling account conflicts.
HttpRequest
The HTTP request object.
tuple
Returns (user, response) tuple. Response is set if enumeration prevention triggered.

save(request)

Creates and saves the new user.
HttpRequest
The HTTP request object.
User
Returns the created user object.

custom_signup(request, user)

Hook for custom signup logic. Override in subclasses.
HttpRequest
The HTTP request object.
User
The newly created user.

AddEmailForm

Form for adding additional email addresses to an account.

Fields

EmailField
required
The email address to add.

Constructor Parameters

User
The user adding the email address.

Methods

save(request)

Adds the email address to the user’s account.
HttpRequest
The HTTP request object.
EmailAddress
Returns the created EmailAddress object.

ChangePasswordForm

Form for changing password when user knows their current password.

Fields

PasswordField
Current password.
SetPasswordField
New password.
PasswordField
New password confirmation.

Constructor Parameters

User
The user changing their password.

Methods

save()

Changes the user’s password.

SetPasswordForm

Form for setting password when user doesn’t have a usable password.

Fields

SetPasswordField
New password.
PasswordField
Password confirmation.

Constructor Parameters

User
The user setting their password.

Methods

save()

Sets the user’s password.

ResetPasswordForm

Form for requesting a password reset.

Fields

EmailField
required
Email address to send reset link to.

Methods

save(request, **kwargs)

Initiates password reset flow.
HttpRequest
The HTTP request object.
PasswordResetTokenGenerator
Custom token generator.
str
Returns the email address.

ResetPasswordKeyForm

Form for completing password reset with a key/token.

Fields

SetPasswordField
New password.
PasswordField
Password confirmation.

Constructor Parameters

User
The user resetting their password.
str
The temporary reset key.

Methods

save()

Resets the user’s password.

RequestLoginCodeForm

Form for requesting a login code (passwordless login).

Fields

EmailField
Email to send code to. Required if phone not enabled.
CharField
Phone to send code to. Only present if phone login enabled.

Usage


ConfirmLoginCodeForm

Form for verifying a login code.

Fields

CharField
The verification code.

Constructor Parameters

str
Expected code for validation.

ReauthenticateForm

Form for reauthenticating an already logged-in user.

Fields

PasswordField
Current password for verification.

Constructor Parameters

User
The user to reauthenticate.

ChangeEmailForm

Form for changing email address with verification.

Fields

EmailField
required
New email address.

Constructor Parameters

str
Current email address.

ChangePhoneForm

Form for changing phone number with verification.

Fields

CharField
required
New phone number.

Constructor Parameters

User
The user changing their phone.
str
Current phone number.

Usage Examples

Custom Signup Form

Password Change Flow

Email Management