python - Django Registration Redux: how to change the unique identifier from username to email and use email as login -


i'm using django-registration-redux in project user registration. uses default user model use username unique identifier.
want discard username , use email unique identifier.
, want use email instead of username login. how achieve this?
, possible without changing auth_user_model settings?

because official doc says"if intend set auth_user_model, should set before creating migrations or running manage.py migrate first time."

you can override registration form this

from registration.forms import registrationform class myregform(registrationform):     username = forms.charfield(max_length=254, required=false, widget=forms.hiddeninput())      def clean_email(self):         email = self.cleaned_data['email']         self.cleaned_data['username'] = email         return email 

and add settings file (read link details)

registration_form = 'app.forms.myregform' 

this set email username field , work email username.

the problem username field has max lenght of 30 in db. emails longer 30 chars raise db exception. solve override user model (read this details).


Comments