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 = helpers.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 = helpers.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).order_by("-id") categories = helpers.pg_records(request, categories, 5) return render(request, 'cadmin/category_list.html', {'categories': categories})
def post_by_tag(request, tag_slug): tag = get_object_or_404(Tag, slug=tag_slug) posts = get_list_or_404(Post.objects.order_by('-id'), tags=tag) posts = helpers.pg_records(request, posts, 5) context = {'tag': tag, 'posts': posts} return render(request, 'myapp/post_by_tag.html', context)
def post_by_category(request, category_slug): category = get_object_or_404(Category, slug=category_slug) posts = get_list_or_404(Post.objects.order_by('-id'), category=category) posts = helpers.pg_records(request, posts, 5) context = {'category': category, 'posts': posts} return render(request, 'myapp/post_by_category.html', context)
def post_list(request): posts = Post.objects.order_by('-id').all() posts = helpers.pg_records(request, posts, 5) return render(request, 'myapp/post_list.html', {'posts': posts})