Registration views

In order to allow the utmost flexibility in customizing and supporting different workflows, django-registration-redux makes use of Django’s support for class-based views. Included in django-registration-redux are two base classes which can be subclassed to implement whatever workflow is required.

class registration.views.RegistrationView

A subclass of Django’s FormView, which provides the infrastructure for supporting user registration.

Useful places to override or customize on a RegistrationView subclass are:

disallowed_url

The URL to redirect to when registration is disallowed. Should be a string, the name of a URL pattern. Default value is registration_disallowed.

form_class

The form class to use for user registration. Can be overridden on a per-request basis (see below). Should be the actual class object; by default, this class is registration.forms.RegistrationForm.

success_url

The URL to redirect to after successful registration. Should be a string, the name of a URL pattern, or a 3-tuple of arguments suitable for passing to Django’s redirect shortcut. Can be overridden on a per-request basis (see below). Default value is None, so that per-request customization is used instead.

template_name

The template to use for user registration. Should be a string. Default value is registration/registration_form.html.

get_form_class()

Select a form class to use on a per-request basis. If not overridden, will use form_class. Should be the actual class object.

get_success_url(user)

Return a URL to redirect to after successful registration, on a per-request or per-user basis. If not overridden, will use success_url. Should be a string, the name of a URL pattern, or a 3-tuple of arguments suitable for passing to Django’s redirect shortcut.

registration_allowed()

Should return a boolean indicating whether user registration is allowed, either in general or for this specific request.

register(form)

Actually perform the business of registering a new user. Receives the registration form. Should return the new user who was just registered.

class registration.views.ActivationView

A subclass of Django’s TemplateView which provides support for a separate account-activation step, in workflows which require that.

Useful places to override or customize on an ActivationView subclass are:

template_name

The template to use for user activation. Should be a string. Default value is registration/activate.html.

activate(*args, **kwargs)

Actually perform the business of activating a user account. Receives any positional or keyword arguments passed to the view. Should return the activated user account if activation is successful, or any value which evaluates False in boolean context if activation is unsuccessful.

get_success_url(user)

Return a URL to redirect to after successful registration, on a per-request or per-user basis. If not overridden, will use success_url. Should be a string, the name of a URL pattern, or a 3-tuple of arguments suitable for passing to Django’s redirect shortcut.

class registration.views.ResendActivationView

A subclass of Django’s FormView` <https://docs.djangoproject.com/en/1.11/ref/class-based-views/generic-editing/#formview>`_ which provides support for resending an activation email to a user.

Useful places to override or customize on an ResendActivationView subclass are:

template_name

The template to use for user activation. Should be a string. Default value is registration/resend_activation_form.html.

resend_activation(self, form)

Given an email, look up user by email and resend activation key if user is not already activated or previous activation key has not expired. Note that if multiple users exist with the given email, no emails will be sent. Returns True if activation key was successfully sent, False otherwise.

render_form_submitted_template(self, form)

Renders resend activation complete template with the submitted email.