我有两个模特
class Market(Model):
title=models.Charfield()
class Product(Model):
title=Models.Charfield()
markets=ManyToMany(Market)我想把产品清单列在我的观点上。我只想为每个市场买到一种产品。怎么做?
product_for_each_market_list=Products.objects.filter()# should be rather simple.. but i can't figure what to do谢谢。
发布于 2012-07-13 10:29:58
我不知道这会有多重,但这是你可以使用的:
Products.objects.filter(markets__in=Market.objects.all()).distinct()https://stackoverflow.com/questions/11466643
复制相似问题