So I know my topic is very vague and I do not know what could be right wording but here I will explain my problem.
This is my modal Course:
class Course(models.Model):
COURSE_TYPE = (
('Theory', 'Theory'),
('Lab', 'Lab')
)
course_id = models.CharField(max_length=100, primary_key=True)
course_name = models.CharField(max_length=200, null=True)
course_type = models.CharField(max_length=200, null=True, choices=COURSE_TYPE)
credit_hours = models.IntegerField(null=True)
contact_hours = models.IntegerField(null=True)
def __str__(self):
return self.course_id + ' - ' + self.course_name
and this is my Professor Modal
class Professor(models.Model):
professor_id = models.AutoField(primary_key=True)
professor_name = models.CharField(max_length=200, null=True)
courses = models.ManytoManyFields(Course, null=True, on_delete=models.CASCADE
working_hours = models.IntegerField(null=True)
available_hours = models.IntegerField(null=True)
Now I have saved data but when I want to retrieve this data on my interface. I want to select course in dropdown then all the professors availabe should be shown in next dropdown.
I have been stuck on this for days. Kindly help me this.