[Answer]-Django: create_new_user_and_profile

1👍

The user model has a create_user method, however it does not create a profile by default, you could use a signal to create a profile each time a new User is created, e.g.

def create_profile(sender, instance, created, **kwargs):
    profile = None
    if created:
        profile, created = Profile.objects.get_or_create(user=instance)

post_save.connect(create_profile, sender=User)

The method added to your model is a custom method which creates a user and triggers create_user_profile, which is then complemented with extra info. IMO, this method should not be part of the CalscopeUserProfile and likely belongs in a (form)view (private) or service function.

Leave a comment