from django.db import models
from food.models import Food
class Recipe(models.Model):
description = models.TextField(null=True, blank=True)
ingridients = models.ManyToManyField(
Food,
through=Ingredients,
through_fields=('recipe', 'food')
)
class Ingredients(models.Model):
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
food = models.ForeignKey(Food, on_delete=models.CASCADE)
quantity = models.DecimalField(null=True, blank=True, max_digits=6, decimal_places=2)
Делал
по документации, но получаю ошибку
in Recipe
through=Ingredients,
NameError: name 'Ingredients' is not defined