I am trying to extend Djangos authentication system and have a problem when trying to create the modelForm for it. As you can see below I have referenced the authentication backend via the suggested OneToOnefield however when I am creating the ModelForm if I try to reference the fields such as 'username', 'password' etc. it spits an error saying they are unknown fields. The form I am creating is a registration from. What am I doing wrong here? Cheers
Model -
class StudentModel(models.Model):
user = models.OneToOneField(User, unique=True)
birth_date = models.DateField()
contact_number = models.IntegerField()
referral = models.CharField(max_length=100, choices=referral_choices)
ModelForm -
from django import forms
from opus_login.models import StudentModel, EmployerModel
class StudentForm(forms.ModelForm):
class Meta:
model = StudentModel
fields = ['username', 'first_name']
Error -
django.core.exceptions.FieldError: Unknown field(s) (username, first_name) specified for StudentModel