本文整理汇总了Python中haystack.views.SearchView.create_response方法的典型用法代码示例。如果您正苦于以下问题:Python SearchView.create_response方法的具体用法?Python SearchView.create_response怎么用?Python SearchView.create_response使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类haystack.views.SearchView
的用法示例。
在下文中一共展示了SearchView.create_response方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_spelling
# 需要导入模块: from haystack.views import SearchView [as 别名]
# 或者: from haystack.views.SearchView import create_response [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"]
示例2: test_spelling
# 需要导入模块: from haystack.views import SearchView [as 别名]
# 或者: from haystack.views.SearchView import create_response [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']
示例3: test_spelling
# 需要导入模块: from haystack.views import SearchView [as 别名]
# 或者: from haystack.views.SearchView import create_response [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']