├── registration_email ├── models.py ├── backends │ ├── __init__.py │ ├── default │ │ ├── __init__.py │ │ └── urls.py │ └── simple │ │ ├── __init__.py │ │ └── urls.py ├── __init__.py ├── static │ └── registration_email │ │ └── css │ │ └── auth.css ├── templates │ └── registration │ │ ├── activation_email_subject.txt │ │ ├── registration_base.html │ │ ├── logout.html │ │ ├── password_reset_done.html │ │ ├── password_reset_complete.html │ │ ├── activate.html │ │ ├── password_change_done.html │ │ ├── registration_complete.html │ │ ├── registration_closed.html │ │ ├── activation_email.txt │ │ ├── activation_complete.html │ │ ├── password_reset_email.html │ │ ├── registration_form.html │ │ ├── password_reset_form.html │ │ ├── password_change_form.html │ │ ├── password_reset_confirm.html │ │ └── login.html ├── locale │ ├── nl │ │ └── LC_MESSAGES │ │ │ ├── django.mo │ │ │ └── django.po │ └── pl │ │ └── LC_MESSAGES │ │ ├── django.mo │ │ └── django.po ├── views.py ├── auth.py ├── auth_urls.py └── forms.py ├── .gitignore ├── DESCRIPTION ├── MANIFEST.in ├── AUTHORS ├── setup.py ├── LICENSE ├── CHANGELOG.txt └── README.md /registration_email/models.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /registration_email/backends/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /registration_email/backends/default/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /registration_email/backends/simple/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | build/ 3 | dist/ 4 | *egg-info/ 5 | 6 | -------------------------------------------------------------------------------- /registration_email/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | __version__ = '0.10' 3 | -------------------------------------------------------------------------------- /registration_email/static/registration_email/css/auth.css: -------------------------------------------------------------------------------- 1 | #id_your_name, label[for="id_your_name"] {display: none;} -------------------------------------------------------------------------------- /registration_email/templates/registration/activation_email_subject.txt: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 | {{ site.name }} {% trans "Account Request" %} 3 | -------------------------------------------------------------------------------- /registration_email/locale/nl/LC_MESSAGES/django.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitlabstudio/django-registration-email/HEAD/registration_email/locale/nl/LC_MESSAGES/django.mo -------------------------------------------------------------------------------- /registration_email/locale/pl/LC_MESSAGES/django.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitlabstudio/django-registration-email/HEAD/registration_email/locale/pl/LC_MESSAGES/django.mo -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Provides a custom authentication backend so that users can signup to the site via their email address instead of a username. Also provides a set of standard templates and sane URL mappings for the whole registration workflow. 2 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS 2 | include LICENSE 3 | include DESCRIPTION 4 | include CHANGELOG.txt 5 | include README.md 6 | recursive-include registration_email *.py *.txt *.html *.mo *.po *.css 7 | prune registration_email/.ropeproject 8 | exclude *.orig *.pyc 9 | -------------------------------------------------------------------------------- /registration_email/templates/registration/registration_base.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block extracss %} 6 | {{ form.media.css }} 7 | {% endblock %} 8 | 9 | {% block main %} 10 | {% block masthead %}{% endblock %} 11 | {% block content %}{% endblock %} 12 | {% endblock %} 13 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Current or previous core committers 2 | 3 | * Martin Brochhaus 4 | 5 | Contributors (in alphabetical order) 6 | 7 | * Alper Cugun (alper) 8 | * Brian Thorne 9 | * Emiliano Dalla Verde Marcozzi (edvm) 10 | * Gijs Nijholt 11 | * Julien Poissonnier (julienp) 12 | * Kars (kaeru) 13 | * Mystic-Mirage 14 | * nanthony 15 | * Pascal Jürgens (trifle) 16 | * Viator (viatoriche) 17 | -------------------------------------------------------------------------------- /registration_email/templates/registration/logout.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %}{% trans "Logout" %}{% endblock %} 6 | 7 | {% block masthead %} 8 |
{% trans "You have been logged out." %}
13 | {% endblock %} 14 | -------------------------------------------------------------------------------- /registration_email/views.py: -------------------------------------------------------------------------------- 1 | """Views for the registration_email app.""" 2 | from django.contrib.auth.views import login 3 | 4 | 5 | def login_remember_me(request, *args, **kwargs): 6 | """Custom login view that enables "remember me" functionality.""" 7 | if request.method == 'POST': 8 | if not request.POST.get('remember_me', None): 9 | request.session.set_expiry(0) 10 | return login(request, *args, **kwargs) 11 | -------------------------------------------------------------------------------- /registration_email/templates/registration/password_reset_done.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %}{% trans "Password reset successful" %}{% endblock %} 6 | 7 | {% block masthead %} 8 |{% trans "We have sent you instructions for setting your password." %}
13 | {% endblock %} 14 | -------------------------------------------------------------------------------- /registration_email/templates/registration/password_reset_complete.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %}{% trans "Password reset complete" %}{% endblock %} 6 | 7 | {% block masthead %} 8 |{% trans "Please login with your new password." %}
13 | {% trans "Login" %} 14 | {% endblock %} 15 | -------------------------------------------------------------------------------- /registration_email/templates/registration/activate.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %}{% trans "Activation failure" %}{% endblock %} 6 | 7 | {% block masthead %} 8 |{% trans "We are sorry but something went wrong!" %}
13 |{% trans "The activation link you provided is broken or was already used." %}
14 | {% endblock %} 15 | -------------------------------------------------------------------------------- /registration_email/templates/registration/password_change_done.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %}{% trans "Password change successful" %}{% endblock %} 6 | 7 | {% block masthead %} 8 |{% trans "Your password has been changed." %}
13 | {% trans "Back to dashboard" %} 14 | {% endblock %} 15 | -------------------------------------------------------------------------------- /registration_email/templates/registration/registration_complete.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %}{% trans "Registration complete" %}{% endblock %} 6 | 7 | {% block masthead %} 8 |{% trans "Thank you for your registration!" %}
13 |{% trans "You will receive an email with an activation link shortly." %}
14 | {% endblock %} 15 | -------------------------------------------------------------------------------- /registration_email/templates/registration/registration_closed.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %}{% trans "Registration closed" %}{% endblock %} 6 | 7 | {% block masthead %} 8 |{% trans "We are sorry but registration is temporarily closed." %}
13 |{% trans "Please come back shortly and try again. We apologize for the inconvenience." %}
14 | {% endblock %} 15 | -------------------------------------------------------------------------------- /registration_email/templates/registration/activation_email.txt: -------------------------------------------------------------------------------- 1 | {% load i18n %} 2 | {% load url from future %} 3 | 4 | 5 | {% blocktrans with site.name as site_name %} 6 | You have asked to register an account at {{ site_name }}. 7 | If this wasn't you, please ignore this email. 8 | 9 | To activate this account, please click the following link within the next 10 | {{ expiration_days }} days: 11 | {% endblocktrans %} 12 | 13 | http://{{ site.domain }}{% url "registration_activate" activation_key=activation_key %} 14 | 15 | {% trans "Sincerely," %} 16 | {{ site.name }} 17 | -------------------------------------------------------------------------------- /registration_email/templates/registration/activation_complete.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %}{% trans "Activation complete" %}{% endblock %} 6 | 7 | {% block masthead %} 8 |{% trans "You may now login with your username and password." %}
13 | {% if not user.is_authenticated %} 14 | {% trans "Login now" %} 15 | {% else %} 16 | {% trans "Home" %} 17 | {% endif %} 18 | {% endblock %} 19 | -------------------------------------------------------------------------------- /registration_email/templates/registration/password_reset_email.html: -------------------------------------------------------------------------------- 1 | {% load i18n %}{% load url from future %}{% autoescape off %} 2 | {% blocktrans %}You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %} 3 | 4 | {% trans "Please go to the following page and choose a new password:" %} 5 | {% block reset_link %} 6 | {{ protocol }}://{{ domain }}{% url 'django.contrib.auth.views.password_reset_confirm' uidb36=uid token=token %} 7 | {% endblock %} 8 | 9 | {% trans "Thanks for using our site!" %} 10 | 11 | {% blocktrans %}The {{ site_name }} team{% endblocktrans %} 12 | 13 | {% endautoescape %} 14 | -------------------------------------------------------------------------------- /registration_email/templates/registration/registration_form.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %}{% trans "Registration form" %}{% endblock %} 6 | 7 | {% block masthead %} 8 |{% trans "Enter your e-mail address below, and we will send instructions for setting a new one." %}
12 | 24 | {% endblock %} 25 | -------------------------------------------------------------------------------- /registration_email/templates/registration/password_change_form.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %}{% trans "Password change" %}{% endblock %} 6 | 7 | {% block masthead %} 8 |{% trans "Please enter your old password, then enter your new password twice." %}
13 | 26 | {% endblock %} 27 | -------------------------------------------------------------------------------- /registration_email/templates/registration/password_reset_confirm.html: -------------------------------------------------------------------------------- 1 | {% extends "registration/registration_base.html" %} 2 | {% load url from future %} 3 | {% load i18n %} 4 | 5 | {% block title %} 6 | {% if validlink %}{% trans "Enter new password" %}{% else %}{% trans "Error resetting password" %}{% endif %} 7 | {% endblock %} 8 | 9 | {% block masthead %} 10 | {% if validlink %} 11 |{% trans "Please enter your new password twice." %}
20 | 32 | {% else %} 33 |{% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}
34 | {% endif %} 35 | {% endblock %} 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to tag
61 |
62 | === 0.4 ===
63 |
64 | - Added registration_base.html template.
65 |
66 | === 0.3 ===
67 |
68 | - making sure to save emails as lower case all the time
69 |
70 | === 0.2.4 ===
71 |
72 | - BUGFIX!! Fixed typo in urls.py. Thanks to `DmitryGit` for reporting this!
73 |
74 | === 0.2.3 ===
75 |
76 | - Replaced usage of `direct_to_template` with `TemplateView` because the former
77 | doesn't exist in Django 1.5 any more.
78 |
79 | === 0.2.2 ===
80 |
81 | - made username generation more robust to avoid name clashes
82 |
83 | === 0.2.1 ===
84 |
85 | - Added method `generate_username` in `forms.py` so you can re-use it in your
86 | own apps.
87 |
88 | === 0.2.0 ===
89 |
90 | - Added new settings: REGISTRATION_EMAIL_REGISTER_SUCCESS_URL and
91 | REGISTRATION_EMAIL_ACTIVATE_SUCCESS_URL. This allows to override the standard
92 | redirect without overriding the urls.py.
93 |
94 | === 0.1.0 ===
95 |
96 | - Added URLs for the simple backend of django-registration.
97 |
98 | === 0.0.1 ===
99 |
100 | - Initial commit
101 |
--------------------------------------------------------------------------------
/registration_email/forms.py:
--------------------------------------------------------------------------------
1 | """Custom registration forms that expects an email address as a username."""
2 | import hashlib
3 | import os
4 |
5 | from django import forms
6 | from django.conf import settings
7 | from django.contrib.auth.forms import AuthenticationForm
8 | from django.contrib.auth.models import User
9 | from django.utils.translation import ugettext_lazy as _
10 |
11 |
12 | try:
13 | from django.contrib.auth import get_user_model
14 | User = get_user_model()
15 | except ImportError:
16 | from django.contrib.auth.models import User
17 |
18 | # I put this on all required fields, because it's easier to pick up
19 | # on them with CSS or JavaScript if they have a class of "required"
20 | # in the HTML. Your mileage may vary. If/when Django ticket #3515
21 | # lands in trunk, this will no longer be necessary.
22 | attrs_dict = {'class': 'required'}
23 |
24 |
25 | def get_md5_hexdigest(email):
26 | """
27 | Returns an md5 hash for a given email.
28 |
29 | The length is 30 so that it fits into Django's ``User.username`` field.
30 |
31 | """
32 | if isinstance(email, str): # for py3
33 | email = email.encode('utf-8')
34 | return hashlib.md5(email).hexdigest()[0:30]
35 |
36 |
37 | def generate_username(email):
38 | """
39 | Generates a unique username for the given email.
40 |
41 | The username will be an md5 hash of the given email. If the username exists
42 | we just append `a` to the email until we get a unique md5 hash.
43 |
44 | """
45 | try:
46 | User.objects.get(email=email)
47 | raise Exception('Cannot generate new username. A user with this email'
48 | 'already exists.')
49 | except User.DoesNotExist:
50 | pass
51 |
52 | username = get_md5_hexdigest(email)
53 | found_unique_username = False
54 | while not found_unique_username:
55 | try:
56 | User.objects.get(username=username)
57 | email = '{0}a'.format(email.lower())
58 | username = get_md5_hexdigest(email)
59 | except User.DoesNotExist:
60 | found_unique_username = True
61 | return username
62 |
63 |
64 | class EmailAuthenticationForm(AuthenticationForm):
65 | remember_me = forms.BooleanField(
66 | required=False,
67 | label=_('Remember me'),
68 | )
69 |
70 | def __init__(self, *args, **kwargs):
71 | super(EmailAuthenticationForm, self).__init__(*args, **kwargs)
72 | self.fields['username'] = forms.CharField(
73 | label=_("Email"), max_length=256)
74 |
75 | def clean_username(self):
76 | """Prevent case-sensitive erros in email/username."""
77 | return self.cleaned_data['username'].lower()
78 |
79 |
80 | class EmailRegistrationForm(forms.Form):
81 | """
82 | Form for registering a new user account.
83 |
84 | Validates that the requested username is not already in use, and
85 | requires the password to be entered twice to catch typos.
86 |
87 | Subclasses should feel free to add any additional validation they
88 | need, but should avoid defining a ``save()`` method -- the actual
89 | saving of collected user data is delegated to the active
90 | registration backend.
91 |
92 | """
93 | email = forms.EmailField(
94 | widget=forms.TextInput(attrs=dict(attrs_dict, maxlength=256)),
95 | label=_("Email")
96 | )
97 | password1 = forms.CharField(
98 | widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
99 | label=_("Password")
100 | )
101 | password2 = forms.CharField(
102 | widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
103 | label=_("Password (repeat)"))
104 | your_name = forms.CharField(required=False)
105 |
106 | def clean_email(self):
107 | """
108 | Validate that the username is alphanumeric and is not already
109 | in use.
110 |
111 | """
112 | email = self.cleaned_data['email'].strip()
113 | try:
114 | User.objects.get(email__iexact=email)
115 | except User.DoesNotExist:
116 | return email.lower()
117 | raise forms.ValidationError(
118 | _('A user with that email already exists.'))
119 |
120 | def clean(self):
121 | """
122 | Verifiy that the values entered into the two password fields match.
123 |
124 | Note that an error here will end up in ``non_field_errors()`` because
125 | it doesn't apply to a single field.
126 |
127 | """
128 | data = self.cleaned_data
129 | if data.get('your_name'):
130 | # Bot protection. The name field is not visible for human users.
131 | raise forms.ValidationError(_('Please enter a valid name.'))
132 | if not 'email' in data:
133 | return data
134 | if ('password1' in data and 'password2' in data):
135 |
136 | if data['password1'] != data['password2']:
137 | raise forms.ValidationError(
138 | _("The two password fields didn't match."))
139 |
140 | self.cleaned_data['username'] = generate_username(data['email'])
141 | return self.cleaned_data
142 |
143 | class Media:
144 | css = {
145 | 'all': (os.path.join(
146 | settings.STATIC_URL, 'registration_email/css/auth.css'), )
147 | }
148 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Important
2 | =========
3 |
4 | This app has been discontinued due to the give-up of django-registration. Also there are a lot of well developed and more extensive alternatives on the market.
5 |
6 | Why don't you check out ``django-allauth``: https://github.com/pennersr/django-allauth
7 |
8 | It's already integrated in our project template (incl. templates & settings): https://github.com/bitmazk/django-project-template/
9 | It's configured the way we used this app.
10 |
11 | django-registration-email
12 | ==========================
13 |
14 | We use
15 | [django-registration](https://bitbucket.org/ubernostrum/django-registration/overview)
16 | in almost all our projects. However, we don't like Django's limited username
17 | and would like to allow our users to sign up via email.
18 |
19 | This project provides a custom authentication backend which allows users to
20 | authenticate via email. We also provide an EmailRegistrationForm which
21 | checks if an email has already been taken.
22 |
23 | Since we still have to store a username and since emails can easily be longer
24 | than 30 characters, the username will be computed as a md5 hexdigest of the
25 | email address.
26 |
27 | We included a ``urls.py`` that overrides all URLs of django-registration
28 | and Django's auth with a clean and sane structure and you will find a default
29 | set of all necessary templates.
30 |
31 | Usage
32 | ======
33 |
34 | Install this package::
35 |
36 | pip install -e git://github.com/bitmazk/django-registration-email#egg=registration_email
37 |
38 | Add ``registration`` and ``registration_email`` to your ``INSTALLED_APPS``::
39 |
40 | INSTALLED_APPS = [
41 | # all your other apps
42 | 'registration',
43 | 'registration_email',
44 | ]
45 |
46 | Update your ``urls.py``::
47 |
48 | url(r'^accounts/', include('registration_email.backends.default.urls')),
49 |
50 | Add some settings to your ``settings.py``::
51 |
52 | ACCOUNT_ACTIVATION_DAYS = 7
53 | AUTHENTICATION_BACKENDS = (
54 | 'registration_email.auth.EmailBackend',
55 | )
56 | LOGIN_REDIRECT_URL = '/'
57 |
58 | Run ``syncdb``::
59 |
60 | ./manage.py syncdb
61 |
62 | Settings
63 | ========
64 |
65 | django-registration-email introduces a new setting:
66 |
67 | REGISTRATION_EMAIL_ACTIVATE_SUCCESS_URL
68 | ---------------------------------------
69 |
70 | Default: ``lambda request, user: '/'``
71 |
72 | Function to return the URL to redirect to after a successful account
73 | activation. If you leave this at ``lambda request, user: '/'`` it will direct
74 | to your base URL.
75 |
76 | REGISTRATION_EMAIL_REGISTER_SUCCESS_URL
77 | ---------------------------------------
78 |
79 | Default: ``lambda request, user: '/'``
80 |
81 | Function to return the URL to redirect to after a successful account
82 | registration. If you leave this at ``lambda request, user: '/'`` it will direct
83 | to your base URL.
84 |
85 | How to use a custom form
86 | ========================
87 |
88 | Let's say you want to collect the user's first name and last name when he
89 | registers. In order to achieve that, you need to do the following:
90 |
91 | __1. Create a custom form__
92 |
93 | Create a new app `my_registration` in your project and give it a `forms.py`
94 | where you override our `EmailRegistrationForm` and your desired extra
95 | fields:
96 |
97 | from django import forms
98 | from registration_email.forms import EmailRegistrationForm
99 |
100 | class CustomEmailRegistrationForm(EmailRegistrationForm):
101 | first_name = forms.CharField()
102 | last_name = forms.CharField()
103 |
104 | Do NOT override the form's `save()` method.
105 |
106 | __2. Override the URL__
107 |
108 | Now you need to tell the registration view that it is supposed to use the
109 | custom form:
110 |
111 | # your main urls.py
112 | ...
113 | from django.conf import settings
114 | from registration.backends.simple.views import RegistrationView
115 | from my_registration.forms import CustomEmailRegistrationForm
116 |
117 | urlpatterns = [
118 | ...
119 | url(
120 | r'^accounts/register/$',
121 | RegistrationView.as_view(
122 | template_name='registration/registration_form.html',
123 | form_class=CustomEmailRegistrationForm,
124 | get_success_url=getattr(
125 | settings, 'REGISTRATION_EMAIL_REGISTER_SUCCESS_URL',
126 | lambda request, user: '/'),
127 | ),
128 | name='registration_register',
129 | ),
130 |
131 | url(r'^accounts/', include('registration_email.backends.default.urls')),
132 | ...
133 | ]
134 |
135 | __3. Create a signal handler__
136 |
137 | In the `urls.py` above I'm using the `SimpleBackend`. When you have a look
138 | at that [backend](https://github.com/nathanborror/django-registration/blob/master/registration/backends/simple/__init__.py#L30)
139 | you will see that the backend sends a signal after creating and logging in the
140 | user. The signal will get all parameters that we need in order to access the
141 | data that has been validated and sent by the form, so let's build a signal
142 | handler:
143 |
144 | # in my_registration.models.py
145 | from django.dispatch import receiver
146 | from registration.signals import user_registered
147 |
148 | @receiver(user_registered)
149 | def user_registered_handler(sender, user, request, **kwargs):
150 | user.first_name = request.POST.get('first_name')
151 | user.last_name = request.POST.get('last_name')
152 | user.save()
153 |
154 | This method has the drawback that you save the user two times in a row. If
155 | you have concerns about performance you would have to create your own
156 | `my_registration.backends.CustomRegistrationBackend` class. That class would
157 | inherit `registration.backends.simple.SimpleBackend` and override the
158 | `register` method.
159 |
160 | But really, we are talking about registration here, I can't imagine how saving
161 | the user twice could do any harm.
162 |
163 |
164 | Troubleshooting
165 | ================
166 |
167 | If you had another value for ``AUTHENTICATION_BACKENDS`` in your
168 | ``settings.py`` before it might be that it is saved in your ``django_session``
169 | table. I found no other way around this than to delete the rows in that table.
170 |
171 | TODO
172 | =====
173 |
174 | * Password reset link points to original django template
175 |
--------------------------------------------------------------------------------
/registration_email/locale/nl/LC_MESSAGES/django.po:
--------------------------------------------------------------------------------
1 | # SOME DESCRIPTIVE TITLE.
2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3 | # This file is distributed under the same license as the PACKAGE package.
4 | # FIRST AUTHOR