本文整理汇总了Python中haystack.query.EmptySearchQuerySet方法的典型用法代码示例。如果您正苦于以下问题:Python query.EmptySearchQuerySet方法的具体用法?Python query.EmptySearchQuerySet怎么用?Python query.EmptySearchQuerySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类haystack.query
的用法示例。
在下文中一共展示了query.EmptySearchQuerySet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from haystack import query [as 别名]
# 或者: from haystack.query import EmptySearchQuerySet [as 别名]
def search(self):
sqs = super(AdvancedSearchForm, self).search()
if isinstance(sqs, EmptySearchQuerySet):
return sqs
topics = sqs.models(Topic)
categories = self.cleaned_data['category']
if categories:
topics = topics.filter(
category_id__in=[c.pk for c in categories])
# See: haystack pull #1141 and #1093
# querying False won't work on elastic
return topics.filter(is_removed=0)
示例2: __init__
# 需要导入模块: from haystack import query [as 别名]
# 或者: from haystack.query import EmptySearchQuerySet [as 别名]
def __init__(self, instance=None, data=empty, **kwargs):
super(HaystackSerializer, self).__init__(instance, data, **kwargs)
if not self.Meta.index_classes and not self.Meta.serializers:
raise ImproperlyConfigured("You must set either the 'index_classes' or 'serializers' "
"attribute on the serializer Meta class.")
if not self.instance:
self.instance = EmptySearchQuerySet()