Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

django - Why allauth EmailAddress matching query does not exist?

I am using dj-rest-auth packages for auth functionality for APIs in my project. But with the login endpoint, I am getting this error.

allauth.account.models.EmailAddress.DoesNotExist: EmailAddress matching query does not exist.

When the user who gets registered from the web can't login from an api endpoint.Do I have to register the email into the allauth Emailaddress Table also if user gets created from web like this.

django views

def save_user(request):
   user = form.save()
   # then create this user email in all auth EmailAddress table ?
   EmailAddress.objects.create(email=user.email..) ??

rest settings

ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 1
ACCOUNT_AUTHENTICATION_METHOD = "username"

OR is there any settings available so that any active users from the system can login through api endpoint?

EDIT I manually created email address table in allauth after user verifies email from web like this. This solved this issue but I am wondering if there's any other solution in the dj-rest-auth package itself beside doing this in the django view ?

 if user is not None and PasswordResetTokenGenerator.check_token(self=account_activation_token, user=user,                                                                     token=token):
 user.is_active = True
 user.save()
 try:
    from allauth.account.models import EmailAddress
    EmailAddress.objects.get_or_create(user=user, email=user.email, verified=True, primary=True)
 except:
      pass
 return redirect('user:login')
question from:https://stackoverflow.com/questions/66046181/why-allauth-emailaddress-matching-query-does-not-exist

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...