Here is a practical example of using a user form and backend that sets the username == address and asks the user only for the email address when registering. In, for example. my_registration.py :
from django.conf import settings from django.contrib.sites.models import RequestSite from django.contrib.sites.models import Site from registration import signals from registration.forms import RegistrationForm from registration.models import RegistrationProfile from registration.backends.default import DefaultBackend class EmailRegistrationForm(RegistrationForm): def __init__(self, *args, **kwargs): super(EmailRegistrationForm,self).__init__(*args, **kwargs) del self.fields['username'] def clean(self): cleaned_data = super(EmailRegistrationForm,self).clean() if 'email' in self.cleaned_data: cleaned_data['username'] = self.cleaned_data['username'] = self.cleaned_data['email'] return cleaned_data class EmailBackend(DefaultBackend): def get_form_class(self, request): return EmailRegistrationForm
In my_registration_urls.py :
from django.conf.urls.defaults import * from django.views.generic.simple import direct_to_template from registration.views import activate from registration.views import register urlpatterns = patterns('', url(r'^activate/complete/$', direct_to_template, { 'template': 'registration/activation_complete.html' }, name='registration_activation_complete'),
Then, in your urls.py kernel urls.py make sure you include:
url(r'^accounts/', include('my_registration_urls')),
source share