當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。