Created
February 26, 2020 18:36
-
-
Save banagale/08dcda94dc0078a1485c9b288748ec96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@receiver(post_save, sender=User) | |
def create_user_profile(sender, instance, created, **kwargs): | |
# When user is created, build user profile and create payinfo instance. | |
# See also accounts.forms.SignupForm.signup for other signup steps | |
if created: | |
profile = Profile.objects.create(user=instance) | |
profile.payment_info = PaymentInfo.objects.create() | |
try: | |
instance.profile.account_type = AccountType.objects.get(name='Basic') | |
except AccountType.DoesNotExist: | |
logger.error('Required AccountType object instance Basic is not available') | |
instance.profile.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment