Re: Complicated relationships

2016-05-23 Thread Gergely Polonkai
I would make Restaurant.dishes a @property that returns all dishes the restaurant's chefs can make: return Dish.objects.filter(chef__restaurant=self) On May 23, 2016 14:46, "Jani Tiainen" wrote: > Something like > > Chef: > # Nothing special here, reverse relations will be done automatical

Re: Complicated relationships

2016-05-23 Thread Jani Tiainen
Something like Chef: # Nothing special here, reverse relations will be done automatically Dish: chef = ForeignKey(Chef) Restaurant: chefs = ManyToMany(Chef) dishes = ManyToMany(Dish) Of course, you need to build something to make sure that restaurant doesn't serve dishes that

Complicated relationships

2016-05-23 Thread Mlati Mudan
I read the django documentation for a simple many-to-many relationship and I get it, but I'm stuck with this kind of complexity. Each restaurant employs many chefs and serves many dishes. Each chef can work for many restaurants and prepare many dishes. Each dish can only be prepared by a singl