title: include extra field in nested serializer with throuth model Django
body: <p>I'm writing a meal tracker, so there are two models, <code>Recipe</code> and <code>Ingredient</code>, which are connected through model <code>RecipeIngredient</code> with extra field <code>quantity</code>.</p>
  
  <p>Here's my models.py:</p>
  
  <pre><code>class Recipe(models.Model):
      name = models.CharField(max_length=100)
      recipe = models.CharField(max_length=200)
      ingredients = models.ManyToManyField(Ingredient, through="RecipeIngredient", related_name='recipes')
  
  class RecipeIngredient(models.Model):
      recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, unique=False)
      ingredient = models.ForeignKey(Ingredient, on_delete=models.CASCADE)
      quantity = models.IntegerField(blank=False)
  
  class Ingredient(models.Model):
      id = models.AutoField(primary_key=True, db_column='ingredient_id')
      name = models.CharField(max_length=100)
      calories = models.IntegerField(blank=True)
  
  </code></pre>
  
  <p>views.py:</p>
  
  <pre><code>class RecipeViewSet(viewsets.ModelViewSet):
      queryset = Recipe.objects.all()
      serializer_class = RecipeSerializer
      permission_classes = (AllowAny,)
  
      def get_queryset(self):
          return Recipe.objects.annotate(
              total_ingredients=Count('ingredients'),
              total_calories=Sum('ingredients__calories'),
              total_quantity=Sum('recipeingredient__quantity')
          )
  class IngredientViewSet(viewsets.ModelViewSet):
      queryset = Ingredient.objects.all()
      serializer_class = IngredientSerializer
      permission_classes = (AllowAny,)
  </code></pre>
  
  <p>serialziers.py:</p>
  
  <pre><code>class RecipeSerializer(serializers.ModelSerializer):
      ingredient_list = IngredientSerializer(source='ingredients', many=True, required=False)
      total_ingredients = serializers.IntegerField(required=False)
      total_calories = serializers.IntegerField(required=False)
      total_quantity = serializers.IntegerField(required=False)
      class Meta:
          model = Recipe
          fields = ('id', 'name', 'ingredient_list', 'recipe', 'total_ingredients', 'total_calories', 'total_quantity')
          depth = 1
  
  class IngredientSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = Ingredient
          fields = ['id', 'name', 'calories']
  </code></pre>
  
  <p>So far, my response looks like this:</p>
  
  <pre><code>  {
        "id": 1,
        "name": "testrecipe",
        "ingredient_list": [
              {
                  "id": 1,
                  "name": "ing0",
                  "calories": 2
              },
              {
                  "id": 2,
                  "name": "ing1",
                  "calories": 4
              },
              {
                  "id": 3,
                  "name": "ing2",
                  "calories": 4
              }
          ],
          "recipe": "recipe discription here",
          "total_ingredients": 3,
          "total_calories": 10,
          "total_quantity": 30
     },
  </code></pre>
  
  <p>I want to include <code>quantity</code> for each ingredient in the list, so that response could look like this:</p>
  
  <pre><code>  {
        "id": 1,
        "name": "testrecipe",
        "ingredient_list": [
              {
                  "id": 1,
                  "name": "ing0",
                  "calories": 2,
                  "quantity":10
              },
              {
                  "id": 2,
                  "name": "ing1",
                  "calories": 4,
                  "quantity":15
              },
              {
                  "id": 3,
                  "name": "ing2",
                  "calories": 4,
                  "quantity":5
              }
          ],
          "recipe": "recipe discription here",
          "total_ingredients": 3,
          "total_calories": 10,
          "total_quantity": 30
     },
  </code></pre>
  
  <p>I can retrieve ingredient's quantity by <code>&lt;ingredient instance&gt;.recipeingredient_set.all()[0].quantity</code> considering this ingredient is only in one recipe, but how can I include this field in serializer, and in which one?</p>