title: How can I add extra data to a ModelMultipleChoiceField?
body: <p>I'm making a calorie counter. The user can pick from a list of Dishes (easy with a <a href="https://docs.djangoproject.com/en/dev/ref/forms/fields/#modelmultiplechoicefield" rel="nofollow noreferrer">ModelMultipleChoiceField</a>), but they also need to specify how many servings of each <code>Dish</code> they had, where the <code>serving_size</code> is a field of my <code>Dish</code> model.</p>
  
  <p>Basically, I want it to look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/ee73M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ee73M.png" alt="There&#39;s a checkbox for each Dish, and underneath each checkbox, there&#39;s a number input field for the number of servings you ate."></a></p>
  
  <p>The problem is that in order to display the strings "4 oz servings" and "slices", I need access to the <code>Dish</code> model when the field is rendered.</p>
  
  <p>What's the best way to do this?</p>
  
  <hr>
  
  <p>I've got 2 rough ideas so far:</p>
  
  <ol>
  <li><p>Create a custom <code>Widget</code> that will render as a checkbox AND a number input field. When the data gets deserialized, it becomes something like this:</p>
  
  <pre><code>{"dish": &lt;Dish model&gt;, "servings": 2.5}
  </code></pre></li>
  <li><p>Just use the regular <code>CheckboxSelectMultiple</code> widget, but add the <code>Dish</code> model itself to the template's context. That way I can do something like this:</p>
  
  <pre><code>{% for dish in form.fountain_dishes %}
      {{dish}}
      I ate &lt;input type="number"&gt; {{dish.context.serving_size}}
  {% endfor %}
  </code></pre>
  
  <p>However, I'm not sure how to make my <code>clean</code> method handle this unexpected data.</p></li>
  </ol>