How to replicate what django-allauth does when it creates a user, or how to programmatically submit a form in django?
I am trying to import a bunch of users from an old database into a new system, and I am running into problems when I just create users and add their email addresses. Apparently allauth does some hidden magic behind the scenes that I'm having trouble figuring out, because when one of these users logs in, I get an error from the email template Invalid block tag on line 298: 'user_display'. Did you forget to register or load this tag?
This doesn't happen when a user that is registered via a form, which subclasses allauth.account.forms.SignupForm
logs in.
I thought that maybe I could just send the data through the form, but it requires a request to save, so I either need to figure out all the things that the SignupForm does when it creates a new user, or I need to figure out how to manually create the user using the form, which means I have to supply a request, or at least a fake request.
I would appreciate any help here.
The way I got around this was to create an EmailAddress
instance from allauth.account.models
for each user, and set primary and verified to True.
EmailAddress.objects.create(user=user, email=user.email, primary=True, verified=True)
This obviously isn't what happens when a new user is signed up, because verified should not be true until the address is verified, but it worked for my purposes.