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)
评论列表
文章目录