开发者

How do I filter for prices using Satchmo/django?

I'd like to find the minimum and maximum prices for a defined category of products.

I'd also like to be able to do the reverse, i.e, find all products given a defined price range.

The problem is 开发者_如何学编程that Satchmo does not have price in it's product model. How can I solve this problem?


Min/max prices for a category:

Product.objects.filter(category=some_category).aggregate(Min('price'), Max('price'))

Products filtered by price range:

Product.objects.filter(price__price__range=(5,10))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜