title: Django ModelChoice Field Conditional ForeignKey
body: <p>I've surfed most of the afternoon and have been at this particular quandry for a while.  </p>
  
  <p>I am trying to figure out how to essentially present a foreign key as a dropdown choice if the user has driven that type of car.  For example purposes and to keep this as easy as possible...</p>
  
  <p>Let's say I have  a<code>Cars</code>, <code>Manufacturers</code> and a <code>UserProfile</code> model.  </p>
  
  <p>I have a model for <code>Cars</code> as so...</p>
  
  <pre><code>class Cars(models.Model):
  
      car_name = models.CharField(max_length=80)    
      class = models.ForeignKey(Manufacturer,null=True,on_delete=models.DO_NOTHING,related_name='car_manufacturer')
  </code></pre>
  
  <p>I have a model for <code>Manufacturers</code> as so...</p>
  
  <pre><code>class Manufacturers(models.Model):
  
          manu_name = models.CharField(max_length=80)  
  </code></pre>
  
  <p>Then I have a <code>UserProfile</code> model....</p>
  
  <pre><code>class Userprofile(models.Model):
  
     user = models.OneToOneField(User,on_delete=models.CASCADE)
     user_name = models.CharField(max_length=80)    
     car_owned = models.ForeignKey(Car,null=True,on_delete=models.DO_NOTHING,related_name='car_owned')
  </code></pre>
  
  <p>All good so far...</p>
  
  <p>I have a view where I am listing all of the <code>Manufacturers</code> and this works fine as well.  It shows all of the manufacturers that I would expect in the form view below.  </p>
  
  <pre><code>class ManufacturerForm(forms.Form):
  
      dropdown = forms.ModelChoiceField(queryset=Manufacturer.objects.all())
  
      def __init__(self, *args, **kwargs):
          super(ManufacturerForm, self).__init__(*args, **kwargs)
          self.fields['dropdown'].widget.attrs['class'] = 'choices1'
          self.fields['dropdown'].empty_label = ''
  </code></pre>
  
  <p>I'm using the FORMVIEW below to display the form...</p>
  
  <pre><code>class ManufacturerView(LoginRequiredMixin,FormView):
      form_class = ManufacturerForm
      template_name = 'Directory/HTMLNAME.html'
  
      def get_form_kwargs(self):
          kwargs = super(ManufacturerView, self).get_form_kwargs()
          kwargs['user'] = self.request.user
          return kwargs
  
      def form_valid(self, form):
          manufacturer = form.cleaned_data['dropdown']
          return HttpResponseRedirect(reverse("NAME:manufacturer",kwargs={'pk':manufacturer.pk}))
  </code></pre>
  
  <p>This all works fine.  However, I can't figure out how to limit the manufacturer dropdown to only the cars the user has driven.  I'm trying to essentially limit the dropdown display to only the manufacturers that are pertinent to the cars the user has owned based on their profile.  I've researched reverse look ups and have also tried something similar to what is outlined below to solve my problem...</p>
  
  <pre><code>class ManufacturerForm(forms.Form):
  
      dropdown = forms.ModelChoiceField(queryset=Manufacturer.objects.filter(car_manufacturer=1)
  
      def __init__(self, *args, **kwargs):
          super(ManufacturerForm, self).__init__(*args, **kwargs)
          self.fields['dropdown'].widget.attrs['class'] = 'choices1'
          self.fields['dropdown'].empty_label = ''
  </code></pre>
  
  <p>But this obviously only gives me record 1 for the <code>Manufacturer</code> model.  I am trying to figure out how to display only the records that are relevant to an individual user based on their car_owned data.  I can list all of the manufacturers and then just display the records that are relevant in a <code>ListView</code>, but I am trying to limit the dropdown to only where there are relevant records in a <code>ListView</code>.  Thanks in advance for any thoughts.</p>