title: how to filter foreign key in django form without passing foreign key value?
body: <p>I have created two models in my django project AddStudent and Fee Entry as shown below.</p>
  
  <p><strong>models.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>class AddStudent(models.Model):
      enrollment_no = models.BigIntegerField(primary_key=True)
      student_name = models.CharField(max_length=500,null=True)
      gender = models.CharField(max_length=1,choices=GENDER_CHOICES)
      course = models.ForeignKey(CourseMaster, on_delete=models.DO_NOTHING, null=True)
      category= models.ForeignKey(CatMaster, on_delete=models.DO_NOTHING, null=True)
      admission_year = models.IntegerField(('year'), choices=YEAR_CHOICES, default=datetime.datetime.now().year)
      college = models.ForeignKey(CollegeMaster, on_delete=models.DO_NOTHING, null=True)
      branch = models.ForeignKey(BranchMaster,on_delete=models.DO_NOTHING, null=True)
      current_semester = models.IntegerField(null=True)
      address = models.CharField(max_length=1000,null=True)
      city = models.CharField(max_length=100,null=True)
      district = models.CharField(max_length=100,null=True)
      state = models.CharField(max_length=100,null=True)
      student_contact = models.BigIntegerField()
      parent_contact = models.BigIntegerField()
  
      def get_absolute_url(self):
          return reverse('add_student:index')
  
      def __str__(self):
          return str(self.enrollment_no) + ' - ' + self.student_name
  
  class FeeEntry(models.Model):
  
      student = models.ForeignKey(AddStudent,on_delete=models.DO_NOTHING)
      fee_detail = models.ForeignKey(FeeMaster,on_delete=models.DO_NOTHING)
      fee_sem = models.IntegerField(null=True)
      payment_date = models.DateField(("Date"), default=datetime.date.today)
      pay_method = models.BooleanField(choices=BOOL_CHOICES)
      cheque_no = models.CharField(max_length = 100, null=True, blank=True)
      bank_name = models.CharField(max_length = 200, null=True, blank=True)
  
      def __str__(self):
          return str(self.id) + ' - ' + str(self.student) + ' - ' + self.student.student_name
  </code></pre>
  
  <p>Now when user search particular student for example student id = 1 than student profile page will open and there is another button addfee. My problem is when user click on add fee all 500 student list is appear in dropdown list. i want to create fee for searched student only. </p>
  
  <p><strong>forms.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>from django import forms
  from .models import FeeEntry, AddStudent
  from bootstrap_modal_forms.mixins import PopRequestMixin, CreateUpdateAjaxMixin
  
  class FeeForm(PopRequestMixin, CreateUpdateAjaxMixin, forms.ModelForm):
      class Meta:
          model = FeeEntry
          fields = ['student', 'fee_detail', 'fee_sem', 'payment_date', 'pay_method','cheque_no','bank_name']
  </code></pre>
  
  <p>above is my forms.py file where field 'student' will generate all 500 student list. I want only selected student for example enrollment_no=1 when user is on enrollment_no 1's page.</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>class FeeCreateView(PassRequestMixin, SuccessMessageMixin,
                           generic.CreateView):
      template_name = 'add_student/create_fee.html'
      form_class = FeeForm
      success_message = 'Success: Book was created.'
      success_url = reverse_lazy('add_student:detail')
  </code></pre>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>path('create/&lt;int:pk&gt;', views.FeeCreateView.as_view(), name='create_fee'),
  </code></pre>
  
  <p>Can anyone tell me what changes are required in this code? or can you share link of similar example like this?</p>