当前位置: 首页>>代码示例>>Python>>正文


Python SearchView.build_page方法代码示例

本文整理汇总了Python中haystack.views.SearchView.build_page方法的典型用法代码示例。如果您正苦于以下问题:Python SearchView.build_page方法的具体用法?Python SearchView.build_page怎么用?Python SearchView.build_page使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在haystack.views.SearchView的用法示例。


在下文中一共展示了SearchView.build_page方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_spelling

# 需要导入模块: from haystack.views import SearchView [as 别名]
# 或者: from haystack.views.SearchView import build_page [as 别名]
    def test_spelling(self):
        # Stow.
        from django.conf import settings

        old = settings.HAYSTACK_CONNECTIONS["default"].get("INCLUDE_SPELLING", None)

        settings.HAYSTACK_CONNECTIONS["default"]["INCLUDE_SPELLING"] = True

        sv = SearchView()
        sv.query = "Nothing"
        sv.results = []
        sv.build_page = lambda: (None, None)
        sv.create_response()
        context = sv.get_context()

        self.assertIn(
            "suggestion",
            context,
            msg="Spelling suggestions should be present even if"
            " no results were returned",
        )
        self.assertEqual(context["suggestion"], None)

        # Restore
        settings.HAYSTACK_CONNECTIONS["default"]["INCLUDE_SPELLING"] = old

        if old is None:
            del settings.HAYSTACK_CONNECTIONS["default"]["INCLUDE_SPELLING"]
开发者ID:acdha,项目名称:django-haystack,代码行数:30,代码来源:test_views.py

示例2: test_spelling

# 需要导入模块: from haystack.views import SearchView [as 别名]
# 或者: from haystack.views.SearchView import build_page [as 别名]
    def test_spelling(self):
        # Stow.
        from django.conf import settings
        old = settings.HAYSTACK_CONNECTIONS['default'].get('INCLUDE_SPELLING', None)

        sv = SearchView()
        sv.query = 'Nothing'
        sv.results = []
        sv.build_page = lambda: (None, None)
        output = sv.create_response()

        # Restore
        settings.HAYSTACK_CONNECTIONS['default']['INCLUDE_SPELLING'] = old

        if old is None:
            del settings.HAYSTACK_CONNECTIONS['default']['INCLUDE_SPELLING']
开发者ID:Koed00,项目名称:django-haystack,代码行数:18,代码来源:test_views.py

示例3: test_spelling

# 需要导入模块: from haystack.views import SearchView [as 别名]
# 或者: from haystack.views.SearchView import build_page [as 别名]
    def test_spelling(self):
        # Stow.
        from django.conf import settings
        old = settings.HAYSTACK_CONNECTIONS['default'].get('INCLUDE_SPELLING', None)

        settings.HAYSTACK_CONNECTIONS['default']['INCLUDE_SPELLING'] = True

        sv = SearchView()
        sv.query = 'Nothing'
        sv.results = []
        sv.build_page = lambda: (None, None)
        sv.create_response()
        context = sv.get_context()

        self.assertIn('suggestion', context,
                      msg='Spelling suggestions should be present even if'
                          ' no results were returned')
        self.assertEqual(context['suggestion'], None)

        # Restore
        settings.HAYSTACK_CONNECTIONS['default']['INCLUDE_SPELLING'] = old

        if old is None:
            del settings.HAYSTACK_CONNECTIONS['default']['INCLUDE_SPELLING']
开发者ID:aptivate,项目名称:django-haystack,代码行数:26,代码来源:test_views.py


注:本文中的haystack.views.SearchView.build_page方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。