2๐
โ
I had a similar issue. Solved it by making the model look a little different:
class Student(User):
nr_indeksu = models.BigIntegerField()
def __unicode__(self):
return unicode(self.user)
This way, when you define the Django form, all needed fields will be rendered for this model. This is because you are saying The student is a user , as opossed to the former the student has a user
The form could look like:
class StudentForm(forms.ModelForm):
class Meta:
model = Student
Edit:
Use a similar approach for teacher model.
If you want to avoid the rendering of some fields, use the fields attribute in the Meta class.
Second Edit:
If you want to preserve the validations and checks of the User form, the form should also inherit from UserCreationForm.
๐คAlvaro
Source:stackexchange.com