title: Django ModelForm passing multiple ManytoMany that are using through?
body: <p>I am trying to figure out how to get two things figured out with Django (1.6) forms. I am looking to create a form using ModelForm with a model that has more then one ManyToManyField using through. I can seem to figure out how to get the ManyToMany items to be displayed in the form. </p>
  
  <p>The one other thing I am trying to figure out is how to split up the form. For example if I wanted a form that looked like this. </p>
  
  <p><strong>Note:</strong> How its part of the Recipe Model (name, desciption) then the ManyToManyField (Fruit and items that go with it.) then another item from the Recipe Model (Fruit_notes) and then the second ManyToManyField...etc </p>
  
  <h2><strong>Form Example:</strong></h2>
  
  <p>Name: __________________ Description: ___________</p>
  
  <hr>
  
  <p>Fruit: ___________  QTY: _________<br>
  Fruit Notes: ____________</p>
  
  <hr>
  
  <p>Veg: ___________ qty: __________<br>
  veg notes:___________</p>
  
  <hr>
  
  <p><strong>models.py File</strong></p>
  
  <pre><code>               from django.db import models
  
  
      class Vegetable(models.Model):
          name = models.CharField(max_length=150, blank=True)
          description = models.TextField(blank=True)
  
          def __unicode__(self):
              return self.name
  
  
      class Fruit(models.Model):
          name = models.CharField(max_length=150, blank=True)
          description = models.TextField(blank=True)
  
          def __unicode__(self):
              return self.name
  
  
  
  
      class Recipe(models.Model):
          name = models.CharField(max_length=450, blank=True)
          description = models.TextField(blank=True)
          fruits = models.ManyToManyField('Fruit', through='RecipeFruit')
          fruit_notes = models.TextField(blank=True)
          vegetables = models.ManyToManyField('Vegetable' through='RecipeVegetable')
          Vegetables_notes = models.TextField()
  
  
      class RecipeVegetable(models.Model):
          recipe = models.ForeignKey(Recipe)
          veg = models.ForeignKey(Vegetable)
          qty = models.FloatField()  
  
  
      class RecipeFruit(models.Model):
          recipe = models.ForeignKey(Recipe)
          fruit = models.ForeignKey(Fruit)
          qty = models.FloatField()
  </code></pre>
  
  <p><strong>forms.py File</strong></p>
  
  <pre><code>    from django import forms
      from django.forms import ModelForm, Textarea
      from django.forms.formsets import formset_factory
      from models import Recipe, Vegetable, Fruit
      from crispy_forms.helper import FormHelper
      from crispy_forms.layout import Submit
  
      class CreateRecipeForm(forms.ModelForm):
  
          class Meta:
              model = Recipe
  
  
          def __init__(self, *args, **kwargs):
              super(CreateRecipeForm, self).__init__(*args, **kwargs)
              self.helper = FormHelper()
              self.helper.form_id = 'id-RecipeForm'
              self.helper.form_class = 'form-inline'
              self.helper.form_method = 'post'
              self.helper.form_action = 'submit_survey'
  
              self.helper.add_input(Submit('submit', 'Submit'))
  </code></pre>
  
  <p>I did come across this question. <a href="https://stackoverflow.com/questions/387686/what-are-the-steps-to-make-a-modelform-work-with-a-manytomany-relationship-with">What are the steps to make a ModelForm work with a ManyToMany relationship with an intermediary model in Django?</a></p>
  
  <p>Looks like a great step toward figuring this out but I am having a hard time grasping on how to bring in two items. (In example, fruit and Vegetable)</p>
  
  <p>If someone could point my in the right direction on this and provide a little example, it would be so greatly appreciated. When looking at the django docs, I don't really see anything that spells this out. </p>