title: How can I create and link many-to-many tables in Django?
body: <p>I am implementing the following schema in a Django app, but I am new to Django's ORM:</p>
  
  <p><a href="https://i.stack.imgur.com/xrCsL.png" rel="nofollow"><img src="https://i.stack.imgur.com/xrCsL.png" alt="meal-menu schema"></a></p>
  
  <p>Briefly, a DayMenu lists multiple MenuItems. (A MenuItem is simply a many-to-many relationship between a DayMenu and a Meal.) Each User selects a MenuItem from the DayMenu. (This choice is represented as a UserItemChoice.)</p>
  
  <p>In our first draft <code>models.py</code> (below), MenuItem is defined as a many-to-many field on the DayMenu model.</p>
  
  <pre><code>from __future__ import unicode_literals
  
  from django.db import models
  
  # Create your models here.
  
  class Meal(models.Model):
  
      # field options: diet
      MEAT = "MEAT"
      VEGETARIAN = "VEGET"
      HALAAL = "HALAA"
  
      DIET_CHOICES = (
          (MEAT, "Meat"),
          (VEGETARIAN, "Vegetarian"),
          (HALAAL, "Halaal"),
      )
  
      # field options: type
      FREE = "FREE"
      PAID = "PAID"
      SKIP = "SKIP"
  
      TYPE_CHOICES = (
          (FREE, "Free"),
          (PAID, "Paid"),
          (SKIP, "Skip"),
      )
  
      # fields
      cost = models.IntegerField(default=10)
      description = models.CharField(max_length=120)
      diet = models.CharField(max_length=5, choices=DIET_CHOICES)
      type = models.CharField(max_length=5, choices=TYPE_CHOICES)
  
  
  class DayMenu(models.Model):
  
      # fields
      date = models.DateField()
      locked = models.BooleanField(default=False)
      item = models.ManyToManyField(Meal)  # TODO: confirm (replaces MenuItem in schema)
  
  
  # class UserItemChoice(models.Model):
  #
  #     # fields
  #     user = models.CharField()  # FIXME
  #     menuitem = models.CharField()  # FIXME
  #     selected = models.BooleanField(default=False)
  #     like = models.NullBooleanField(default=None)
  </code></pre>
  
  <p>How do we define UserItemChoice given that:</p>
  
  <ul>
  <li>it is itself a many-to-many relationship</li>
  <li>it links to a many-to-many field rather than a (explicit) model</li>
  <li>it would (ideally?) be a many-to-many field on the built-in user table</li>
  </ul>