【发布时间】:2016-09-14 05:17:30
【问题描述】:
我正在使用django-filter 和django-pure-pagination 扩展
class BuyFilterView(PaginationMixin, FilterView):
filterset_class = ProductFilter
template_name = "buy_filter.html"
context_object_name = "goods"
paginate_by = 50
def get_context_data(self, **kwargs):
context = super(BuyFilterView, self).get_context_data(**kwargs)
context['cart'] = Cart.objects.get(user=self.request.user)
return context
class ProductFilter(FilterSet):
country = ChoiceFilter(choices=country_values)
brand = ChoiceFilter(choices=brand_values)
type = ChoiceFilter(choices=type_values)
class Meta:
model = Goods
fields = {
'country': ['exact'],
'brand': ['exact'],
'type': ['exact'],
}
Goods 模型中的某些项目具有空白价格值。我想将它们从查询集中排除。我该怎么做?
【问题讨论】:
标签: python django django-queryset django-filter