How to create a proper user using django allauth?

  • If I only have an email address
  • If I don’t care about the atm password (later, the user will enter through the "token" link)

In pure Django, I would just do this:

from django.contrib.auth.models import User
user = User.objects.create_user(username=email, email=email)

But django allauth comes with this stuff EmailAdress. I just need to create one of them, and then I'm fine?

from allauth.account.models import EmailAddress
EmailAddress.objects.create(user=user, email=email, primary=True, verified=False)

I do not want to break the logic of django allauth, and the existing adapter methods do not fit my needs.

EDIT : replaced setup_user_emailbyEmailAddress

EDIT2 : replace add_emailwith create, want to installprimary=True

+4
source share

All Articles