2013-09-24 13:54:41 +00:00
|
|
|
import datetime
|
|
|
|
from django.shortcuts import render, get_object_or_404
|
|
|
|
from blog.models import Post
|
|
|
|
|
2013-10-01 20:55:35 +00:00
|
|
|
def mainpage(request):
|
2013-10-01 21:02:48 +00:00
|
|
|
last_posts = Post.objects.filter(draft=False).order_by('-created_at')[:5]
|
2013-10-01 19:17:41 +00:00
|
|
|
return render(request, 'blog/listing.html', {'posts': last_posts})
|
2013-09-24 13:54:41 +00:00
|
|
|
|
2013-10-01 20:55:35 +00:00
|
|
|
def index(request):
|
2013-10-01 21:02:48 +00:00
|
|
|
last_posts = Post.objects.filter(draft=False).order_by('-created_at')
|
2013-10-01 20:55:35 +00:00
|
|
|
return render(request, 'blog/listing.html', {'posts': last_posts})
|
|
|
|
|
2013-09-24 13:54:41 +00:00
|
|
|
def read(request, year, month, day, slug):
|
2013-10-01 21:02:48 +00:00
|
|
|
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);
|
2013-09-24 13:54:41 +00:00
|
|
|
return render(request, 'blog/view.html', {'post': post})
|
|
|
|
|
2013-10-01 19:18:11 +00:00
|
|
|
def taglist(request, tag):
|
2013-10-01 21:02:48 +00:00
|
|
|
posts = Post.objects.filter(tags__slug=tag, draft=False)
|
2013-10-01 19:18:11 +00:00
|
|
|
return render(request, 'blog/listing.html', {'posts': posts})
|
|
|
|
|
2013-09-24 13:54:41 +00:00
|
|
|
def feed(request):
|
|
|
|
return render(request, 'blog/feed.xml', {})
|
|
|
|
|