本文整理匯總了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()