Perfect, the "extra fields" and an intermediary relationship model
were exactly what I needed. Thanks.

On Thu, Dec 25, 2008 at 3:14 PM, Ramiro Morales <cra...@gmail.com> wrote:
>
> On Thu, Dec 25, 2008 at 5:13 PM, Chris Czub <chris.c...@gmail.com> wrote:
>>
>>
>> I think I need to use a ManyToManyField for this but I'm having
>> trouble finagling it to be the way I want. Here's what I have right
>> now but I can't figure out where to put the amount and unit for the
>> ingredients:
>>
>> class Ingredient(models.Model):
>>    name        = models.CharField(max_length=255)
>>    amount      = models.IntegerField()
>>    unit           = models.CharField(max_length=12)
>>
>>    def __unicode__(self):
>>        return self.name
>>    class Admin:
>>        pass
>>
>> class Recipe(models.Model):
>>    name        = models.CharField(max_length=255)
>>    ingredients = models.ManyToManyField('Ingredient')
>>
>>    def __unicode__(self):
>>        return self.name
>>    class Admin:
>>        pass
>>
>>
>> Any ideas would be greatly appreciated :)
>
> Take a look at the relevant documentation:
>
> http://docs.djangoproject.com/en/dev/topics/db/models/#many-to-many-relationships
> http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships
>
> also, the m2m_through m2m_intermediary and m2m_through example:
>
>  http://www.djangoproject.com/documentation/models/m2m_intermediary/
>
> (tests/modeltests/m2m_intermediary/models.py in the Django source tree.)
> and the m2m_through example (tests/modeltests/m2m_through/models.py in
> the Django source tree.)
>
> HTH
>
> --
>  Ramiro Morales
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to