I had trouble coming up with a decriptive "subject" for this. Sorry.
I'm working on an app for planning balanced daily diets. And I'm
having trouble figuring out how to set up my models. I have:
Ingredient(models.Model):
ingredient_name = CharField(max_length=50)
unit = CharField(max_length=15)
calories = DecimalField(max_digits=6, decimal_places=2)
Recipe(models.Model):
recipe_name = CharField(max_length=50)
ingredients = ManyToMany(Ingredient)
amount = DecimalField(max_digits=6, decimal_places=2)
An ingredient can be in many recipes and a recipe has many
ingredients. The thing is, in a Recipe I want to have an arbitrary
number of ingredients, and I need for each ingredient to be associated
with an amount. I could use multiple ForeignKey fields from in Recipe
to Ingredient, and multiple amount fields in Recipe, but that seems
klunky. Is there a "right" way to do this?
Thanks,
Steve Bergman
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---