Removed drafts from blog post results
This commit is contained in:
parent
84fd0e38e3
commit
3893932ade
@ -3,19 +3,19 @@ from django.shortcuts import render, get_object_or_404
|
|||||||
from blog.models import Post
|
from blog.models import Post
|
||||||
|
|
||||||
def mainpage(request):
|
def mainpage(request):
|
||||||
last_posts = Post.objects.order_by('-created_at')[:5]
|
last_posts = Post.objects.filter(draft=False).order_by('-created_at')[:5]
|
||||||
return render(request, 'blog/listing.html', {'posts': last_posts})
|
return render(request, 'blog/listing.html', {'posts': last_posts})
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
last_posts = Post.objects.order_by('-created_at')
|
last_posts = Post.objects.filter(draft=False).order_by('-created_at')
|
||||||
return render(request, 'blog/listing.html', {'posts': last_posts})
|
return render(request, 'blog/listing.html', {'posts': last_posts})
|
||||||
|
|
||||||
def read(request, year, month, day, slug):
|
def read(request, year, month, day, slug):
|
||||||
post = get_object_or_404(Post, created_at__year=int(year), created_at__month=int(month), created_at__day=int(day), slug=slug);
|
post = get_object_or_404(Post, created_at__year=int(year), created_at__month=int(month), created_at__day=int(day), slug=slug, draft=False);
|
||||||
return render(request, 'blog/view.html', {'post': post})
|
return render(request, 'blog/view.html', {'post': post})
|
||||||
|
|
||||||
def taglist(request, tag):
|
def taglist(request, tag):
|
||||||
posts = Post.objects.filter(tags__slug=tag)
|
posts = Post.objects.filter(tags__slug=tag, draft=False)
|
||||||
return render(request, 'blog/listing.html', {'posts': posts})
|
return render(request, 'blog/listing.html', {'posts': posts})
|
||||||
|
|
||||||
def feed(request):
|
def feed(request):
|
||||||
|
Loading…
Reference in New Issue
Block a user