Using Django Models and Foreign key relation to add data

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):


        ('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.

This is not something that Django can handle itself. When you want this type of client-side functionality, you need to use JavaScript.

In this case, you could create a Django view that takes a Course as a parameter and returns the options for the dropdown as HTML.

Your JavaScript would then listen for the event of the Course dropdown being clicked on, and use an AJAX call to call that Django view, using the results to populate the Professors dropdown.

In part, the specifics for this would depend upon what JavaScript framework you’re using.