title: Pass model objects to choices field in django
body: <p>I have a model called <code>Student</code> that has a manytomany relationship with a model called <code>Courses</code>. I have another model called <code>Attend</code> in which I want to get all the courses the student is taking and pass it in as a select menu containing the courses the student is taking. I tried to get the id using the foreign key "student" and then get courses belonging to that student and put it in a list and pass it to choices but it didn't work obviously. I would like to know how I can get the courses belonging to the student to appear in the select menu. </p>
  
  <p>Here is my model.</p>
  
  <pre><code>class Attend(models.Model):
      student = models.ForeignKey(Student, on_delete=models.CASCADE, default="")
      time_signed_in = models.DateTimeField(auto_now_add=True)
      isSignedIn = models.BooleanField(default=False)
      # Below does not work, I get an error 'ForeignKey' object has no attribute 'id'
  
      #courses = User.objects.get(id=student.id).courses
      course = models.ForeignKey(Course, on_delete=models.CASCADE) 
  </code></pre>