当前位置: 首页>>代码示例>>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;未经允许,请勿转载。