Hi,
I searched about this subject and found only a few very old posts, so
maybe there is a better solution now.

As you may guess the model I'd like to code is similar to the Pizza -
Toppings you know from the "Creating Models" documentation:

class Topping(models.Model):
    # ...

class Pizza(models.Model):
    # ...
    toppings = models.ManyToManyField(Topping)


And what if I need to say that I can have two or three times the same
topping on my pizza? Something like twice mozzarella cheese and 3
times green olives topping?

I though about an intermediary class and indeed this is the same
solution found in those old posts mentioned before:

class Topping(models.Model):
    # ...

class ToppingAndQuantity(models.Model):
    amount = models.IntegerField()
    topping = models.ForeignKey(Topping)

class Pizza(models.Model):
    # ...
    toppings = models.ManyToManyField(ToppingAndQuantity)


I think it's ugly.
Can you suggest me a better solution?
It's that intermediary class really needed?

Thank you,
Giovanni.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to