(request)
return render(request, 'tags_list.html', context=context)
Show posts by user
Show posts by user
Show posts by user
def tags_list(request):
    """
    Show posts by user
    """
    page = request.GET.get('page', 1)
    query = request.GET.get('query', '')

    count = Count('post', filter=Q(post__is_toplevel=True))

    db_query = Q(name__icontains=query) if query else Q()
    cache_key = '' if query else TAGS_CACHE_KEY

    tags = Tag.objects.annotate(nitems=count).filter(db_query)
    tags = tags.order_by('-nitems')

    # Create the paginator
    paginator = CachedPaginator(cache_key=cache_key,
                                object_list=tags,
                                per_page=settings.POSTS_PER_PAGE)

    # Apply the votes paging.
    tags = paginator.get_page(page)

    context = dict(tags=tags, tab='tags', query=query)

    return render(request, 'tags_list.html', context=context)
def tags_list ( request ) : page = request . GET . get ( 'page' , 1 ) query = request . GET . get ( 'query' , '' ) count = Count ( 'post' , filter = Q ( post__is_toplevel = True ) ) db_query = Q ( name__icontains = query ) if query else Q ( ) cache_key = '' if query else TAGS_CACHE_KEY tags = Tag . objects . annotate ( nitems = count ) . filter ( db_query ) tags = tags . order_by ( '-nitems' ) # Create the paginator paginator = CachedPaginator ( cache_key = cache_key , object_list = tags , per_page = settings . POSTS_PER_PAGE ) # Apply the votes paging. tags = paginator . get_page ( page ) context = dict ( tags = tags , tab = 'tags' , query = query ) return render ( request , 'tags_list.html' , context = context )