Jump to >

This documentation covers Djblets 2.x. You can see the latest Djblets documentation or all other versions.

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]

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

unicode

Raises

django.core.exceptions.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 raised. Creation always occurs in its own transaction, ensuring it’s immediately saved and preventing potential lookup problems when there’s a conflict.

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, or None if there was a conflict when creating it.

Return type

django.contrib.auth.models.User

Raises

Exception – An unexpected exception occurred.