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


Python views.SearchView类代码示例

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


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

示例1: test_initial_data

 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>')
开发者ID:akaariai,项目名称:django-haystack,代码行数:7,代码来源:views.py

示例2: test_initial_data

 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)
开发者ID:Koed00,项目名称:django-haystack,代码行数:9,代码来源:test_views.py

示例3: test_spelling

    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,代码行数:16,代码来源:test_views.py

示例4: test_spelling

    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,代码行数:28,代码来源:test_views.py

示例5: __call__

 def __call__(self, request, slug):
     self.slug = slug
     try:
         return SearchView.__call__(self, request)
     except PermissionDenied:
         if request.user.is_authenticated():
             raise
         path = request.build_absolute_uri()
         return redirect_to_login(path)
开发者ID:kamni,项目名称:django-sphinxdoc,代码行数:9,代码来源:views.py

示例6: test_spelling

    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,代码行数:24,代码来源:test_views.py

示例7: __call__

 def __call__(self, request, slug):
     self.slug = slug
     return SearchView.__call__(self, request)
开发者ID:indexofire,项目名称:gork,代码行数:3,代码来源:views.py

示例8: __init__

 def __init__(self):
     SearchView.__init__(self, form_class=ProjectSearchForm, template='docs/search.html')
开发者ID:indexofire,项目名称:gork,代码行数:2,代码来源:views.py

示例9: test_empty_results

 def test_empty_results(self):
     sv = SearchView()
     self.assert_(isinstance(sv.get_results(), EmptySearchQuerySet))
开发者ID:akaariai,项目名称:django-haystack,代码行数:3,代码来源:views.py

示例10: test_empty_results

 def test_empty_results(self):
     sv = SearchView()
     sv.request = HttpRequest()
     sv.form = sv.build_form()
     self.assertTrue(isinstance(sv.get_results(), EmptySearchQuerySet))
开发者ID:Koed00,项目名称:django-haystack,代码行数:5,代码来源:test_views.py


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