def search(request): query = get_query(request) page = get_page(request) qd = request.GET.copy() if 'page' in qd: qd.pop('page') posts = None if query: qset = ( Q(title__icontains=query) | Q(content__icontains=query) ) posts = Post.objects.filter(qset, status='publish').distinct().order_by('-date') response = render_to_response('post/post_list.html', { 'query': query, 'posts': posts, 'page': page, 'pagi_path': qd.urlencode(), }) response.set_cookie('search', request.META['REMOTE_ADDR'], max_age=5) return response
def search(request): query = get_query(request) page = get_page(request) qd = request.GET.copy() if 'page' in qd: qd.pop('page') posts = None if query: qset = (Q(title__icontains=query) | Q(content__icontains=query)) posts = Post.objects.filter( qset, status='publish').distinct().order_by('-date') response = render_to_response( 'post/post_list.html', { 'query': query, 'posts': posts, 'page': page, 'pagi_path': qd.urlencode(), }) response.set_cookie('search', request.META['REMOTE_ADDR'], max_age=5) return response
def comment_list(request): page = get_page(request) comments = Comment.objects.in_public() return render_to_response('comment/comment_list.html', { 'comments': comments, 'page': page, 'current': 'comments', }, context_instance=RequestContext(request))
def archive_view(request, year, month): posts = Post.objects.get_post_by_date(year, month) page = get_page(request) return render_to_response('post/post_list.html', { 'year': year, 'month': month, 'posts': posts, 'path': request.path, 'page': page, }, context_instance=RequestContext(request))
def category_view(request, slug): cat = get_object_or_404(Category, slug=slug) posts = Post.objects.get_post_by_category(cat) page = get_page(request) return render_to_response('post/post_list.html', { 'category': cat, 'posts': posts, 'path': request.path, 'page': page, }, context_instance=RequestContext(request))
def archive_view(request, year, month): posts = Post.objects.get_post_by_date(year, month) page = get_page(request) return render_to_response('post/post_list.html', { 'year': year, 'month': month, 'posts': posts, 'path': request.path, 'page': page, }, context_instance=RequestContext(request) )
def category_view(request, slug): cat = get_object_or_404(Category, slug=slug) posts = Post.objects.get_post_by_category(cat) page = get_page(request) return render_to_response('post/post_list.html', { 'category': cat, 'posts': posts, 'path': request.path, 'page': page, }, context_instance=RequestContext(request) )
def index(request, tag=None): page = get_page(request) if tag: tags = get_object_or_404(Tag, name=tag) posts = TaggedItem.objects.get_by_model(Post, tags).filter(type='post', status='publish').order_by('-date') else: posts = Post.objects.get_post() return render_to_response('post/post_list.html', { 'posts': posts, 'page': page, }, context_instance=RequestContext(request) )
def index(request, tag=None): page = get_page(request) if tag: tags = get_object_or_404(Tag, name=tag) posts = TaggedItem.objects.get_by_model(Post, tags).filter( type='post', status='publish').order_by('-date') else: posts = Post.objects.get_post() return render_to_response('post/post_list.html', { 'posts': posts, 'page': page, }, context_instance=RequestContext(request))