本文整理汇总了Python中wagtail.wagtailsearch.index.Indexed方法的典型用法代码示例。如果您正苦于以下问题:Python index.Indexed方法的具体用法?Python index.Indexed怎么用?Python index.Indexed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wagtail.wagtailsearch.index
的用法示例。
在下文中一共展示了index.Indexed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_boosts
# 需要导入模块: from wagtail.wagtailsearch import index [as 别名]
# 或者: from wagtail.wagtailsearch.index import Indexed [as 别名]
def get_boosts():
boosts = set()
for model in apps.get_models():
if issubclass(model, Indexed):
for search_field in get_search_fields(model.get_search_fields()):
boost = search_field.boost
if boost is not None:
boosts.add(boost)
return boosts
示例2: test_inheritance
# 需要导入模块: from wagtail.wagtailsearch import index [as 别名]
# 或者: from wagtail.wagtailsearch.index import Indexed [as 别名]
def test_inheritance(self):
self.assertTrue(issubclass(CustomContent, index.Indexed))
self.assertTrue(issubclass(CustomContent, models.Model))
# fields
示例3: test_inheritance
# 需要导入模块: from wagtail.wagtailsearch import index [as 别名]
# 或者: from wagtail.wagtailsearch.index import Indexed [as 别名]
def test_inheritance(self):
self.assertTrue(issubclass(TwoColumn, index.Indexed))
self.assertTrue(issubclass(TwoColumn, models.Model))
# fields
示例4: test_inheritance
# 需要导入模块: from wagtail.wagtailsearch import index [as 别名]
# 或者: from wagtail.wagtailsearch.index import Indexed [as 别名]
def test_inheritance(self):
self.assertTrue(issubclass(Card, index.Indexed))
self.assertTrue(issubclass(Card, AbstractCard))
# meta
示例5: chooser
# 需要导入模块: from wagtail.wagtailsearch import index [as 别名]
# 或者: from wagtail.wagtailsearch.index import Indexed [as 别名]
def chooser(request, app_label, model_name, filter_name=None):
try:
model = apps.get_model(app_label, model_name)
chooser = registry.choosers[model]
except (LookupError, ValueError, KeyError):
raise Http404
qs = chooser.get_queryset(request)
is_searchable = issubclass(model, Indexed)
is_searching = is_searchable and request.GET.get('q')
if is_searching:
qs = qs.search(request.GET['q'])
if filter_name is not None:
try:
filter_func = registry.filters[model, filter_name]
except KeyError:
raise Http404
qs = filter_func(qs)
paginator, page = paginate(request, qs, per_page=10)
ajax = 'ajax' in request.GET
context = {
'chooser': chooser,
'chooser_url': request.path,
'opts': model._meta,
'paginator': paginator,
'page': page,
'object_list': page.object_list,
'is_searchable': is_searchable,
'is_searching': is_searching,
}
if ajax:
return render(request, 'wagtailmodelchooser/results.html', context)
else:
return render_modal_workflow(
request,
'wagtailmodelchooser/modal.html',
'wagtailmodelchooser/modal.js',
context)