manyToManyField question

Posted by dotty on Stack Overflow See other posts from Stack Overflow or by dotty
Published on 2010-06-07T09:49:31Z Indexed on 2010/06/07 9:52 UTC
Read the original article Hit count: 211

Filed under:
|
|

Hay guys, I'm writing a simple app which logs recipes.

I'm working out my models and have stumbled across a problem

My Dish models needs to have many Ingredients. This is no problem because i would do something like this

ingredients = models.ManyToManyfield(Ingredient)

No problems, my dish now can have many ingrendients.

However, the problem is that the ingredient needs to come in different quantities.

I.E 4 eggs, 7 tablespoons sugar

My Ingredient Model is very simple at the moment

class Ingredient(models.Model):
    name = models.TextField(blank=False)
    slug = models.SlugField(blank=True)

How would i go about work out this problem? What fields would i need to add, would i need to use a 'through' attribute on my ManyToManyfield to solve this problem?

© Stack Overflow or respective owner

Related posts about python

Related posts about django