當前位置: 首頁>>代碼示例>>Python>>正文


Python index.SearchField方法代碼示例

本文整理匯總了Python中wagtail.wagtailsearch.index.SearchField方法的典型用法代碼示例。如果您正苦於以下問題:Python index.SearchField方法的具體用法?Python index.SearchField怎麽用?Python index.SearchField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wagtail.wagtailsearch.index的用法示例。


在下文中一共展示了index.SearchField方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: prepare_field

# 需要導入模塊: from wagtail.wagtailsearch import index [as 別名]
# 或者: from wagtail.wagtailsearch.index import SearchField [as 別名]
def prepare_field(self, obj, field):
        if isinstance(field, SearchField):
            yield (unidecode(self.prepare_value(field.get_value(obj))),
                   get_weight(field.boost))
        elif isinstance(field, RelatedFields):
            sub_obj = getattr(obj, field.field_name)
            if sub_obj is None:
                return
            if callable(sub_obj):
                sub_obj = sub_obj()
            if isinstance(sub_obj, Manager):
                sub_objs = sub_obj.all()
            else:
                sub_objs = [sub_obj]
            for sub_obj in sub_objs:
                for sub_field in field.fields:
                    for value in self.prepare_field(sub_obj, sub_field):
                        yield value 
開發者ID:wagtail,項目名稱:wagtail-pg-search-backend,代碼行數:20,代碼來源:backend.py

示例2: get_search_fields

# 需要導入模塊: from wagtail.wagtailsearch import index [as 別名]
# 或者: from wagtail.wagtailsearch.index import SearchField [as 別名]
def get_search_fields(search_fields):
    for search_field in search_fields:
        if isinstance(search_field, SearchField):
            yield search_field
        elif isinstance(search_field, RelatedFields):
            for sub_field in get_search_fields(search_field.fields):
                yield sub_field 
開發者ID:wagtail,項目名稱:wagtail-pg-search-backend,代碼行數:9,代碼來源:utils.py


注:本文中的wagtail.wagtailsearch.index.SearchField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。