ZXCA
ZXCA

Reputation: 91

Anyone knows a good hack to make django-registration use emails as usernames?

I am planning to do email-registration-activation on my site which will be launched very soon. I have just started looking at django-registration and I am open to other email-registration-activation system available on django.

My only requirement is that for my site, I don't actually use usernames. Rather, user logs in with their emails and passwords. I want to get an expert's opinion how to modify django-registration cleanly and safely for this purpose.

If there are easier solutions which are scalable, feel free to post up here.

Upvotes: 3

Views: 1497

Answers (2)

Alireza Savand
Alireza Savand

Reputation: 3498

Since Django 1.5 now it possible to have custom auth.User and make email address as username.

Upvotes: 0

miku
miku

Reputation: 188114

We used django-registration with a custom backend, where we overwrote (or defined) the clean method of the registration form:

def clean(self):
    ...
    # use the email as the username 
    if 'email' in self.cleaned_data:
        self.cleaned_data['username'] = self.cleaned_data['email']

There are other ways:

Note that by default, usernames can be only 30 chars long. You'll need a hack for that, too:

Upvotes: 6

Related Questions