I want to create a model for teachers and he will has a user to login to the system. I implemented this by one-to-one relation between Teacher model and User model, but I can't get my head around making a form for Teacher model and in the same time I want to create user for him/her, please note I'm using CreateView generic view. models.py
class Teacher(models.Model): GENDER_CHOICES = ( (MALE, _('Male')), (FEMALE, _('Female')), ) gender = models.CharField(max_length=1, verbose_name=_('Gender'), choices=GENDER_CHOICES) civil_id = models.CharField(max_length=12, verbose_name=_('Civil ID')) phone_number = models.CharField(max_length=15, verbose_name=_('Phone Number')) job_title = models.CharField(max_length=15, verbose_name=_('Title')) user = models.OneToOneField(to=User, related_name='teacher_profile') def enable(self): """ Enable teacher profile :return: """ self.user.is_active = True self.user.save() def disable(self): """ Disable teacher profile :return: """ self.user.is_active = False self.user.save() -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7bab5925-e2ec-408b-94ca-6a63f419243c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.