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


Python SearchForm.search_qs方法代码示例

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


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

示例1: index

# 需要导入模块: from search.forms import SearchForm [as 别名]
# 或者: from search.forms.SearchForm import search_qs [as 别名]
def index(request):
    accept = request.META.get('HTTP_ACCEPT_LANGUAGE', '')
    user_langs = get_user_languages_from_request(request)
    
    if 'q' in request.REQUEST:
        form = SearchForm(request.user, user_langs, request.REQUEST)
    else:
        form = SearchForm(request.user, user_langs)
    
    qs = SearchQuerySet().none()
    
    display_mode = 'all'
    
    if form.is_valid():
        qs = form.search_qs(SearchQuerySet().models(Video))
        display_mode = form.cleaned_data.get('display', 'all')
        
    if settings.HAYSTACK_SEARCH_ENGINE == 'dummy' and settings.DEBUG:
        q = request.REQUEST.get('q', '')
        qs = Video.objects.filter(title__icontains=q)
    
    context = {
        'query': request.REQUEST.get('q', ''),
        'form': form,
        'display_mode': display_mode
    }
        
    return object_list(request, queryset=qs,
                       paginate_by=30,
                       template_name='search/index.html',
                       template_object_name='result',
                       extra_context=context)   
开发者ID:MechanisM,项目名称:mirosubs,代码行数:34,代码来源:views.py

示例2: search

# 需要导入模块: from search.forms import SearchForm [as 别名]
# 或者: from search.forms.SearchForm import search_qs [as 别名]
    def search(self, rdata, user, testing=False):
        sqs = SearchQuerySet().result_class(VideoSearchResult) \
                .models(Video)
        
        rdata['q'] = rdata['q'] or u' '
        q = rdata.get('q')

        if q:
            sqs = SearchForm.apply_query(q, sqs)
            form = SearchForm(rdata, sqs=sqs)
        else:
            form = SearchForm(rdata)
        
        if form.is_valid():
            qs = form.search_qs(sqs)
        else:
            qs = SearchQuerySet().none()    

        #result = [item.object for item in qs]
        #qs1 = Video.objects.filter(title__contains=rdata['q'])
        #for o in qs1:
        #    if not o in result:
        #        print o.title
        
        display_views = form.get_display_views()
        output = render_page(rdata.get('page', 1), qs, 20, display_views=display_views)
        output['sidebar'] = render_to_string('search/_sidebar.html', dict(form=form, rdata=rdata))
        
        if testing:
            output['sqs'] = qs
        
        return output
开发者ID:adncentral,项目名称:unisubs,代码行数:34,代码来源:rpc.py


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