Anyone knows a good hack to make django-registrati

2019-03-22 02:52发布

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.

2条回答
我只想做你的唯一
2楼-- · 2019-03-22 03:28

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

查看更多
forever°为你锁心
3楼-- · 2019-03-22 03:32

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:

查看更多
登录 后发表回答