Reputation: 618
I have problem with model built like this:
class Topping(models.Model):
name = models.CharField(max_length=30)
class Pizza(models.Model):
cook = models.ForeignKey(Cook)
name = models.CharField(max_length=50)
toppings = models.ManyToManyField(Topping)
I'm trying to select all toppings used by provided cook on his pizzas.
on SQL I could use select * from Toppings t where t.id IN(select topping_id from Pizzas where cook_id = ?)
or some other way (surely more efficient :P ). Problem is I'm bound to use django models, because of underlying dependencies, like paging.
Because it's database used by many applications it would be great if it could be done without changing models...
Upvotes: 3
Views: 72