1👍
You can use a signal to create a Teacher
whenever the user completes the registration form. A hint would be the following case, I am creating a UserProfile automatically after the user completes the registration form
class UserProfile(models.Model):
user = models.OneToOneField(User, related_name="profile")
class Meta:
verbose_name_plural = "User Profiles"
def __unicode__(self):
return self.user.username
def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
By using the signal post_save
whenever a new user registers, the function create_user_profile
will run, and a new profile will be created for that user.
Another way would be creating a form for the Teacher
model, and validating both forms, the registration form and the teach form on the same view.
I didn’t want to write the whole code with your case the teacher, but I wanted to give you a hint on how to do it. Hope it helps.
Source:stackexchange.com