Django-allauth with multiple profile models -
i have django project in there multiple profile models, each having foreign key user model. uses django-allauth
registration.
currently, when registering using social account, user registers, user , socialaccount created, user redirected form fill out, depending on profile type s/he chose earlier, , after filling out form correct profile type created.
i'd if user, socialaccount , profile type instances created in same step, after user fills out profile specific form. there anyway can without changing allauth's
code? wouldn't hard modifying allauth, i'd rather not maintain custom copy of 3rd party app if can helped.
using custom adapter out, because not have access request.
take @ allauth.account.signals.user_signed_up
signal, triggered after user (social or normal) signs up. can stuff account there:
from django.dispatch import receiver allauth.account.signals import user_signed_up @receiver(user_signed_up) def do_stuff_after_sign_up(sender, **kwargs): request = kwargs['request'] user = kwargs['user'] # stuff user user.save()
from django-allauth repo:
# typically followed `user_logged_in` (unless, e-mail verification kicks in) user_signed_up = signal(providing_args=["request", "user"])
to learn how use signals in django, read the official documentation it.
i hope helps you!
edit
i'm glad found way through problem, since middlewares loaded always, suggest using approach proposed. socialaccount
module django-allauth
provide signals. among them, can find allauth.socialaccount.signals.social_account_added
:
# sent after user connects social account local account. social_account_added = signal(providing_args=["request", "sociallogin"])
with handler similar written, can check user model required fields, , call redirect shortcut, or return httpresponseredirect object redirects view shows/handle form.
Comments
Post a Comment