我正在使用 django oscar 开发电子商务网站。产品已列出,我必须应用过滤器(例如年份、价格等)。我们可以为这个过滤功能使用 oscar facet 吗?
我已尝试根据oscar 文档添加以下内容,但不知道如何使其工作并在我的前端呈现。
OSCAR_SEARCH_FACETS = {
'fields': OrderedDict([
('product_class', {'name': _('Type'), 'field': 'product_class'}),
('rating', {'name': _('Rating'), 'field': 'rating'}),
]),
'queries': OrderedDict([
('price_range',
{
'name': _('Price range'),
'field': 'price',
'queries': [
# This is a list of (name, query) tuples where the name will
# be displayed on the front-end.
(_('0 to 20'), u'[0 TO 20]'),
(_('20 to 40'), u'[20 TO 40]'),
(_('40 to 60'), u'[40 TO 60]'),
(_('60+'), u'[60 TO *]'),
]
}),
])
}
甚至可以使用它来过滤产品,还是有其他方法?