本文整理汇总了Python中haystack.views.SearchView.build_form方法的典型用法代码示例。如果您正苦于以下问题:Python SearchView.build_form方法的具体用法?Python SearchView.build_form怎么用?Python SearchView.build_form使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类haystack.views.SearchView
的用法示例。
在下文中一共展示了SearchView.build_form方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_initial_data
# 需要导入模块: from haystack.views import SearchView [as 别名]
# 或者: from haystack.views.SearchView import build_form [as 别名]
def test_initial_data(self):
sv = SearchView(form_class=InitialedSearchForm)
sv.request = HttpRequest()
form = sv.build_form()
self.assert_(isinstance(form, InitialedSearchForm))
self.assertEqual(form.fields['q'].initial, 'Search for...')
self.assertEqual(form.as_p(), u'<p><label for="id_q">Search:</label> <input type="text" name="q" value="Search for..." id="id_q" /></p>')
示例2: test_initial_data
# 需要导入模块: from haystack.views import SearchView [as 别名]
# 或者: from haystack.views.SearchView import build_form [as 别名]
def test_initial_data(self):
sv = SearchView(form_class=InitialedSearchForm)
sv.request = HttpRequest()
form = sv.build_form()
self.assertTrue(isinstance(form, InitialedSearchForm))
self.assertEqual(form.fields['q'].initial, 'Search for...')
para = form.as_p()
self.assertTrue(u'<label for="id_q">Search:</label>' in para)
self.assertTrue(u'value="Search for..."' in para)
示例3: test_empty_results
# 需要导入模块: from haystack.views import SearchView [as 别名]
# 或者: from haystack.views.SearchView import build_form [as 别名]
def test_empty_results(self):
sv = SearchView()
sv.request = HttpRequest()
sv.form = sv.build_form()
self.assertTrue(isinstance(sv.get_results(), EmptySearchQuerySet))