File: simple-workflow.rst

package info (click to toggle)
python-django-registration 2.0.4-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 676 kB
  • sloc: python: 1,203; makefile: 84
file content (71 lines) | stat: -rw-r--r-- 2,419 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
.. _simple-workflow:
.. module:: registration.backends.simple

The simple one-step workflow
============================

As an alternative to the :ref:`HMAC <hmac-workflow>` and
:ref:`model-based <model-workflow>` two-step (registration and
activation) workflows, ``django-registration`` bundles a one-step
registration workflow in ``registration.backends.simple``. This
workflow is deliberately as simple as possible:

1. A user signs up by filling out a registration form.

2. The user's account is created and is active immediately, with no
   intermediate confirmation or activation step.

3. The new user is logged in immediately.


Configuration
-------------

To use this workflow, simply include the URLconf
``registration.backends.simple.urls`` somewhere in your site's own URL
configuration. For example:

.. code-block:: python

   from django.conf.urls import include, url

   urlpatterns = [
       # Other URL patterns ...
       url(r'^accounts/', include('registration.backends.simple.urls')),
       # More URL patterns ...
   ]

To control whether registration of new accounts is allowed, you can
specify the setting :data:`~django.conf.settings.REGISTRATION_OPEN`.

Upon successful registration, the user will be redirected to the
site's home page -- the URL ``/``. This can be changed by subclassing
``registration.backends.simple.views.RegistrationView`` and overriding
the method ``get_success_url()``.

The default form class used for account registration will be
:class:`registration.forms.RegistrationForm`, although this can be
overridden by supplying a custom URL pattern for the registration view
and passing the keyword argument ``form_class``, or by subclassing
``registration.backends.simple.views.RegistrationView`` and either
overriding ``form_class`` or implementing
:meth:`~registration.views.RegistrationView.get_form_class()`, and
specifying the custom subclass in your URL patterns.


Templates
---------

The one-step workflow uses only one custom template:

**registration/registration_form.html**

Used to show the form users will fill out to register. By default, has
the following context:

``form``
    The registration form. This will likely be a subclass of
    :class:`~registration.forms.RegistrationForm`; consult `Django's
    forms documentation
    <https://docs.djangoproject.com/en/stable/topics/forms/>`_ for
    information on how to display this in a template.