def ajax_page(request, page): if request.method == 'GET': mimetype = 'application/json' news = News.objects.all() pager = get_page(news, 5, page) slug_next = "none" if pager.has_next(): slug_next = reverse('news:index', kwargs={"page": pager.next_page_number()}) arr = [] for new in pager: arr.append(NewsWrapper(new, page=pager.number, slug_next=slug_next)) return HttpResponse(to_json(arr), mimetype)
def ajax_category_page(request, category_slug, page): if request.method == 'GET': mimetype = 'application/json' category = Category.objects.get(slug=category_slug) news = News.objects.filter(category=category) pager = get_page(news, 5, page) slug_next = "none" if pager.has_next(): slug_next = reverse('news:category', kwargs={"category_slug": category_slug, "page": pager.next_page_number()}) arr = [] for new in pager: arr.append(NewsWrapper(new, page=pager.number, slug_next=slug_next)) return HttpResponse(to_json(arr), mimetype)