def add_page(request, category_name_url): context = RequestContext(request) category_name = decode_url(category_name_url) if request.method == 'POST': form = PageForm(request.POST) if form.is_valid(): page = form.save(commit=False) cat = Category.objects.get(name=category_name) page.category = cat page.views = 0 page.save() return category(request, category_name_url) else: print form.errors else: form = PageForm() return render_to_response('rango/add_page.html', {'category_name_url': category_name_url, 'category_name': category_name, 'form': form, 'cat_list': get_category_list() }, context)
def add_page(request, category_name_url): context = RequestContext(request) category_name = decode_url(category_name_url) if request.method == 'POST': form = PageForm(request.POST) if form.is_valid(): page = form.save(commit=False) cat = Category.objects.get(name=category_name) page.category = cat page.views = 0 page.save() return category(request, category_name_url) else: print form.errors else: form = PageForm() return render_to_response( 'rango/add_page.html', { 'category_name_url': category_name_url, 'category_name': category_name, 'form': form, 'cat_list': get_category_list() }, context)
def category(request, category_name_url): context = RequestContext(request) category_name = decode_url(category_name_url) context_dict = { 'category_name_url': category_name_url, 'cat_list': get_category_list() } try: category = Category.objects.get(name=category_name) pages = Page.objects.filter(category=category) context_dict['pages'] = pages context_dict['category'] = category except Category.DoesNotExist: # Will trigger the template to display the 'no category' message. pass # This is a bug when redirected to Category? I think. if request.method == 'POST': query = request.POST.get('query', '').strip() if query: result_list = run_query(query) context_dict['result_list'] = result_list return render_to_response('rango/category.html', context_dict, context)
def category(request, category_name_url): context = RequestContext(request) category_name = decode_url(category_name_url) context_dict = {'category_name_url': category_name_url, 'cat_list': get_category_list()} try: category = Category.objects.get(name=category_name) pages = Page.objects.filter(category=category) context_dict['pages'] = pages context_dict['category'] = category except Category.DoesNotExist: # Will trigger the template to display the 'no category' message. pass # This is a bug when redirected to Category? I think. if request.method == 'POST': query = request.POST.get('query', '').strip() if query: result_list = run_query(query) context_dict['result_list'] = result_list return render_to_response('rango/category.html', context_dict, context)