Django rest auth email instead of username

后端 未结 2 774
没有蜡笔的小新
没有蜡笔的小新 2020-12-15 07:43

I have a django project in which I am using Django-rest-auth to do authentication. I want to use email with password to authenticate the user and n

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 08:07

    Following setting worked:

    #This is required otherwise it asks for email server
    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
    # ACCOUNT_EMAIL_REQUIRED = True
    # AUTHENTICATION_METHOD = 'EMAIL'
    # ACCOUNT_EMAIL_VERIFICATION = 'optional'
    
    ACCOUNT_AUTHENTICATION_METHOD = 'email'
    ACCOUNT_EMAIL_REQUIRED = True   
    ACCOUNT_USERNAME_REQUIRED = False
    
    #Following is added to enable registration with email instead of username
    AUTHENTICATION_BACKENDS = (
     # Needed to login by username in Django admin, regardless of `allauth`
     "django.contrib.auth.backends.ModelBackend",
    
     # `allauth` specific authentication methods, such as login by e-mail
     "allauth.account.auth_backends.AuthenticationBackend",
    )
    

提交回复
热议问题