def category(request, category_name_slug): context_dict={} context_dict['result_list'] = None context_dict['query'] = None if request.method == 'POST': query = request.POST['query'].strip() if query: result_list = run_query(query) context_dict['result_list'] = result_list context_dict['query'] = query try: category = Category.objects.get(slug=category_name_slug) context_dict['category_name'] = category.name pages = Page.objects.filter(category=category).order_by('-views') context_dict['pages'] = pages context_dict['category'] = category context_dict['category_name_slug'] = category_name_slug except Category.DoesNotExist: pass if not context_dict['query']: context_dict['query'] = category.name return render(request, 'rango/category.html', context_dict)
def search(request): result_list = [] if request.method == 'POST': query = request.POST['query'].strip() if query: # Run our Bing function to get the results list! result_list = run_query(query) return render(request, 'rango/search.html', {'result_list': result_list})
def search(request): result_list = [] query = None if request.method == 'POST': query = request.POST['query'].strip() if query: result_list = run_query(query) return render(request, 'rango/search.html', { 'query': query, 'result_list': result_list })
def show_category(request, category_name_slug): context_dict = {} try: category = Category.objects.get(slug=category_name_slug) pages = Page.objects.filter(category=category).order_by('-views') context_dict['pages'] = pages context_dict['category'] = category except Category.DoesNotExist: context_dict['category'] = None context_dict['pages'] = None result_list = [] if request.method == 'POST': query = request.POST['query'].strip() if query: result_list = run_query(query) context_dict['query'] = query context_dict['result_list'] = result_list return render(request, 'rango/category.html', context_dict)