views.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:watchfilms_django_website 作者: zhengyizoey 项目源码 文件源码
def index(request):
    context = {}
    context['movie_list'] = []
    context['types'] = TYPES
    if request.method == 'GET':
        movie_type = request.GET.get('type')
        q = request.GET.get('q')
        if q:  # ?????????????????
            context['movie_list'] = conn['spider']['movie'].find({'title': {'$regex': q}})
            context['current_cat'] = '????"{}"'.format(q)
        elif movie_type:  # ??????????
            if movie_type.encode('utf-8') in context['types']:
                context['movie_list'] = conn['spider']['movie'].find({'types': movie_type})
                context['current_cat'] = movie_type
            else:
                return HttpResponse('??????')
        else:  # ??????????????
            context['movie_list'] = conn['spider']['movie'].find()
            context['current_cat'] = '????'
    return render(request, 'watchfilm/index.html', context)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号