djblets.auth.forms¶
Common forms for authentication tasks.
These forms can be used either directly or as a base for more specific forms. They’re designed to take some of the complexity out of creating authentication-related forms not otherwise provided by Django.
-
class
RegistrationForm
(request=None, *args, **kwargs)[source]¶ Bases:
django.forms.forms.Form
A standard registration form collecting basic account information.
This form prompts the user for a username, a password (and a confirmation on that password), e-mail address, first name, and last name. It then validates these, attempting to create a
User
.This class can be extended by subclasses to provide additional fields.
-
clean_password2
()[source]¶ Validate that the two supplied passwords match.
If they do not match, validation will fail, and an error will be supplied to the user.
Returns: The password supplied on the form. Return type: str Raises: ValidationError
– If the passwords do not match.
-
save
()[source]¶ Save the form, creating a user if validation passes.
The
User
will be created with the provided username, e-mail address, password, and full name. If there are failures in creating this user, or there’s an existing user with the given name, an error will be raisd.Subclasses that want to override this can call the parent’s py:meth:save and modify the resulting user, if
None
is not returned.Returns: The newly-created user. Return type: User
-