在纯Django中我会这样做:
from django.contrib.auth.models import User
user = User.objects.create_user(username=email, email=email)
但是django allauth带有这个EmailAdress
的东西。我是否也必须创建其中一个然后我很好?
from allauth.account.models import EmailAddress
EmailAddress.objects.create(user=user, email=email, primary=True, verified=False)
我不想破坏某些django allauth逻辑,existing adapter methods不符合我的需要。
编辑:将setup_user_email
替换为EmailAddress
EDIT2 :将add_email
替换为create
,想要设置primary=True
答案 0 :(得分:0)
The canonical way to create a user seems to be stuck in the SignupForm.save()
method:
Edit: It's actually one level higher in the SignupView
, which first calls the SignupForm.save()
and then calls account.utils.complete_signup()
, which sends the user_signed_up
signal: