コード例 #1
0
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}
コード例 #2
0
ファイル: views.py プロジェクト: kaidin/tips_diary
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}
コード例 #3
0
ファイル: views.py プロジェクト: kaidin/tips_diary
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}
コード例 #4
0
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
    }