python - how do I change 'username-password login' to 'email-password login' on django-registration -
How will I change 'username-password login' to 'e-password login' on the Dejaanga registration
< / Div>
You can not easily store email in django.contrib.auth.model.User
Name field, so you will need a different auth backend. Place the following somewhere and add your AUTHENTICATION_BACKENDS
to its code. Import the user class email backend (object) from Django.contrib.auth.models
: "django.contrib.auth.models.user.user's e-mail field" Certified "DF credentials against (self, email = none, password = none): Try to use email if this email is given: For user in user.objects.filter (email = email): If user.check_password (password): return user def get_user (auto, user_id): try: user.doccuts Return any user. Objects.jet (pk = user_id), none.
Again, in your thoughts, django.contrib.auth.authenticate
. < / P>
Two things to note:
- You may want to put the default
AUTHENTICATION_BACKEND
in there, especially if you want to use the DEGENGO ADMIN . - If users are signing themselves without any username, then you have to create one for them. I use Base 64 version
Set the username anywhere (such as in your new user form) in a save mode:
Import UUID, Binanias Username = Binisci.b2A_base (UUID4). Bytes)
Comments
Post a Comment