4
votes

I am using django-registration 2.0.4 (https://django-registration.readthedocs.org/en/2.0.4/, https://github.com/ubernostrum/django-registration) with Django 1.8 and am trying to customise the registration form and application itself. While I am able to customise the form, I am stuck at using an email as username.

I don't need to change anything in Django's backend since simple removing the username field in the form and using the input email as username in the backend would be enough.

I have found this (Django-Registration: Email as username) for example but it is a couple of years old and I didn't manage to get it running yet.

How would I approach this the right way to implement said functionality? Has anyone solved this problem with a recent version already?

Edit:

Since I was asked for code: There isn't much that is relevant to this problem since it isn't a code problem but a question regarding how to extend or change the django plugin.

However, my current, boring, forms.py, as it is in the link I linked:

class MyCustomForm(forms.Form):
    email = Email(required=True)
    password1 = forms.CharField(widget=forms.PasswordInput(), label="Password")
    password2 = forms.CharField(widget=forms.PasswordInput(), label="Repeat your password")

    def clean_password(self):
        if self.data['password1'] != self.data['password2']:
            raise forms.ValidationError('Passwords are not the same')
        return self.data['password1']

urls.py

...
url(r'^accounts/register/$', RegistrationView.as_view(form_class=InsuranceForm), name='registration_register'),
url(r'^accounts/', include('registration.backends.hmac.urls')),
...
1
You should add some code and traceback so that we could help you.Çağatay Barın
I have added some code, but I feel as if it doesn't help at all since this isn't where my problem or question lays :xShin

1 Answers

1
votes

I have done this using custom user models.

https://docs.djangoproject.com/en/1.10/topics/auth/customizing/#auth-custom-user

There is a full example in the docs above that you will have to slightly modify to achieve your aims.