def get(self, request): if len(request.GET) > 1: formset = PageBlockQueryFormSet(request.GET) if not formset.is_valid(): return HttpResponseBadRequest('invalid query') pages = formset.get_query() else: formset = PageBlockQueryFormSet() pages = Page.objects.all() paginator, pages = paginate(request, pages.order_by('title')) for page in pages: page.can_choose = True return render(request, self.template_name, { 'base_url': replace_page_in_query(request.GET.urlencode(), None), 'formset': formset, 'pages': pages, })
def replace_page_param(query, page_number, page_key='p'): """ Replaces ``page_key`` from query string with ``page_number``. """ return conditional_escape( replace_page_in_query(query, page_number, page_key))
def replace_page_param(query, page_number, page_key='p'): """ Replaces ``page_key`` from query string with ``page_number``. """ return conditional_escape(replace_page_in_query(query, page_number, page_key))
def replace_page(query_string, page_number): return replace_page_in_query(query_string, page_number)