To ease and automate the process of validating user information during registration, several form classes (built using Django's newforms library) are provided: a base RegistrationForm and subclasses which provide specific customized functionality. All of the forms described below are found in registration.forms.
Form for registering a new user account.
Validates that the requested username is not already in use, and requires the password to be entered twice to catch typos.
Subclasses should feel free to add any additional validation they need, but should either preserve the base save() or implement a save() which accepts the profile_callback keyword argument and passes it through to RegistrationProfile.objects.create_inactive_user().
Fields:
Non-validation methods:
Creates the new User and RegistrationProfile, and returns the User.
This is essentially a light wrapper around RegistrationProfile.objects.create_inactive_user(), feeding it the form data and a profile callback (see the documentation on create_inactive_user() for details) if supplied.
As explained above, subclasses may add any additional validation they like, but must either preserve the save() method or implement a save() method with an identical signature.
Three subclasses are included as examples, and as ready-made implementations of useful customizations:
Subclass of RegistrationForm which disallows registration with email addresses from popular free webmail services; moderately useful for preventing automated spam registrations.
To change the list of banned domains, subclass this form and override the attribute bad_domains.