Esempio n. 1
0
def post_detail_view(request,year,month,day,post):
    post=get_object_or_404(Post,slug=post,publish__year=year,publish__month=month,publish__day=day)
    comments=post.comments.filter(active=True)
    csubmit=False
    form=CommentForm()
    if request.method=='POST':
        form=CommentForm(request.POST)
        if form.is_valid():
            newcomment=form.save(commit=False)
            newcomment.post=post
            newcomment.save()
            csubmit=True
    d={'post':post,'form':form,'csubmit':csubmit,'comments':comments}
    return render(request,'myApp/post_detail.html',d)
Esempio n. 2
0
	post_list=Post.objects.all()
	paginator=Paginator(post_list,2)
	page_number=request.GET.get('page')
	try:
		post_list=paginator.page(page_number)
	except PageNotAnInteger:
		post_list=paginator.page(1)
	except EmptyPage:
		post_list=paginator.page(paginator.num_pages)
	d={'post_list':post_list}
	return render(request,'myApp/post_list.html',d)
def post_detail_view(request,year,month,day,post):
	post=get_object_or_404(Post,slug=post,publish__year=year,publish__month=month,publish__day=day)
	comments=post.comments.filter(active=True)
 	csubmit=False
    form=CommentForm()
    if request.method=='POST':
        form=CommentForm(request.POST)
        if form.is_valid():
            newcomment=form.save(commit=False)
            newcomment.post=post
            newcomment.save()
            csubmit=True
	d={'post':post,'form':form,'csubmit':csubmit,'comments':comments}
	return render(request,'myApp/post_detail.html',d)
def mail_send_view(request,id):
	post=get_object_or_404(Post,id=id,status='published')
	form=EmailSendForm()
	if request.method=='POST':
		form=EmailSendForm(request.POST)
		if form.is_valid():