def tag_list(request): if request.user.is_superuser: tags = Tag.objects.order_by('-id').all() else: tags = Tag.objects.filter( author__user__username=request.user.username).order_by('-id') tags = pg_records(request, tags, 5) return render(request, 'cadmin/tag_list.html', {'tags': tags})
def post_list(request): if request.user.is_superuser: posts = Post.objects.order_by('-id').all() else: posts = Post.objects.filter( author__user__username=request.user.username).order_by('-id') posts = pg_records(request, posts, 5) return render(request, 'cadmin/post_list.html', {'posts': posts})
def category_list(request): if request.user.is_superuser: categories = Category.objects.order_by('-id').all() else: categories = Category.objects.filter( author__user__username=request.user.username) categories = pg_records(request, categories, 5) return render(request, 'cadmin/category_list.html', {'categories': categories})
def post_by_category(request, category_slug): category = get_object_or_404(Category, slug=category_slug) allPosts = get_list_or_404(Post.objects.order_by('-id'), category=category) posts = pg_records(request, allPosts, 5) context = {'posts': posts, 'category': category} return render(request, 'blog/post_by_category.html', context)
def post_list(request): allPosts = get_list_or_404(Post.objects.order_by('-id').all()) posts = pg_records(request, allPosts, 5) return render(request, 'blog/post_list.html', {'posts': posts})