On 29/02/2016 2:09 PM, James Schneider wrote:
Again, I'm making some assumptions about your models. If the above code
snippets don't work (aside from typos), please post up your models.py
file(s) so that we can adjust accordingly.


I think James is right. Maybe the answer to the above question is in your subject line.

If I was doing a recipe app I would need to scratch my head. For example, do I permit an ingredient to also be a recipe? In other words, are ingredients simply raw materials or can they be separate concoctions. I'm no chef but I suspect recipes include separately prepared components which are brought together during the cooking process or at the latest just before serving.

Maybe your "step" is a sub-recipe.

So the real question is about your expertise. If you are a chef all you need here is how to do many-to-many relationships. There must be heaps of manufacturer apps out there. They generally go under the label of "bill-of-materials". It seems to me quite similar to recipes.

Anyway ...

I'm building a much simpler ingredients system with substances and mixtures where a mixture is a substance having relationships with other substances. Here is my setup:

class Substance(models.Model):
ingredients = models.ManyToManyField('self', symmetrical=False, blank=True, through='Substance_Ingredients')
    ...

class Substance_Ingredients(models.Model):
    substance = models.ForeignKey('Substance', null=True, blank=True,
        related_name='base_substance')
    ingredient = models.ForeignKey('Substance', null=True, blank=True,)
    proportion = models.DecimalField(null=True, blank=True)
    ...

Hope this helps

Mike

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56D3C15E.5050507%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to