def index(request): categories = Category.objects.filter(publicated=True) posts = Post.objects.filter(publicated=True) most_viewed = posts.order_by('-viewed')[:10] page = pagination(request, posts, 10) if request.GET.get('json'): return page return {'categories': categories, 'most_viewed': most_viewed, 'page': page}
def index(request): categories = Category.objects.filter(publicated=True) posts = Post.objects.filter(publicated=True) most_viewed = posts.order_by("-viewed")[:10] page = pagination(request, posts, 15) if request.GET.get("json"): return page return {"categories": categories, "most_viewed": most_viewed, "page": page}
def category(request, slug): categories = Category.objects.filter(publicated=True) category = get_object_or_404(Category, slug=slug) posts = Post.objects.filter(category=category, publicated=True) most_viewed = posts.order_by("-viewed")[:10] page = pagination(request, posts, 15) if request.GET.get("json"): return page return {"categories": categories, "category": category, "most_viewed": most_viewed, "page": page}
def category(request, slug): categories = Category.objects.filter(publicated=True) category = get_object_or_404(Category, slug=slug) posts = Post.objects.filter(category=category, publicated=True) most_viewed = posts.order_by('-viewed')[:10] page = pagination(request, posts, 10) if request.GET.get('json'): return page return { 'categories': categories, 'category': category, 'most_viewed': most_viewed, 'page': page }