from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils import timezone
from django.core.urlresolvers import reverse

from .models import BlogPost


def index(request):
    all_blog_posts = BlogPost.objects.order_by('-pub_date')
    context = {
        'all_blog_posts': all_blog_posts,
    }
    return render(request, 'Blog/index.html', context)

def detail(request, post_id):
    post = get_object_or_404(BlogPost, pk=post_id)
    context = {
        'post': post
    }
    return render(request, 'Blog/detail.html', context)

def new(request):
    new_post_text = request.GET.get('post_text', '')
    if new_post_text == '':
        return render(request, 'Blog/new.html')
    else:
        new_blog_post = BlogPost(post_text=new_post_text, pub_date=timezone.now())
        new_blog_post.save()
        return HttpResponseRedirect(reverse('blog:detail', args=(new_blog_post.id,)))

f518d0f69da9b5038acb122890c740ee0d668b23
<mask token>


def detail(request, post_id):
    post = get_object_or_404(BlogPost, pk=post_id)
    context = {'post': post}
    return render(request, 'Blog/detail.html', context)


<mask token>

<mask token>


def detail(request, post_id):
    post = get_object_or_404(BlogPost, pk=post_id)
    context = {'post': post}
    return render(request, 'Blog/detail.html', context)


def new(request):
    new_post_text = request.GET.get('post_text', '')
    if new_post_text == '':
        return render(request, 'Blog/new.html')
    else:
        new_blog_post = BlogPost(post_text=new_post_text, pub_date=timezone
            .now())
        new_blog_post.save()
        return HttpResponseRedirect(reverse('blog:detail', args=(
            new_blog_post.id,)))

<mask token>


def index(request):
    all_blog_posts = BlogPost.objects.order_by('-pub_date')
    context = {'all_blog_posts': all_blog_posts}
    return render(request, 'Blog/index.html', context)


def detail(request, post_id):
    post = get_object_or_404(BlogPost, pk=post_id)
    context = {'post': post}
    return render(request, 'Blog/detail.html', context)


def new(request):
    new_post_text = request.GET.get('post_text', '')
    if new_post_text == '':
        return render(request, 'Blog/new.html')
    else:
        new_blog_post = BlogPost(post_text=new_post_text, pub_date=timezone
            .now())
        new_blog_post.save()
        return HttpResponseRedirect(reverse('blog:detail', args=(
            new_blog_post.id,)))

from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils import timezone
from django.core.urlresolvers import reverse
from .models import BlogPost


def index(request):
    all_blog_posts = BlogPost.objects.order_by('-pub_date')
    context = {'all_blog_posts': all_blog_posts}
    return render(request, 'Blog/index.html', context)


def detail(request, post_id):
    post = get_object_or_404(BlogPost, pk=post_id)
    context = {'post': post}
    return render(request, 'Blog/detail.html', context)


def new(request):
    new_post_text = request.GET.get('post_text', '')
    if new_post_text == '':
        return render(request, 'Blog/new.html')
    else:
        new_blog_post = BlogPost(post_text=new_post_text, pub_date=timezone
            .now())
        new_blog_post.save()
        return HttpResponseRedirect(reverse('blog:detail', args=(
            new_blog_post.id,)))

from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils import timezone
from django.core.urlresolvers import reverse

from .models import BlogPost


def index(request):
    all_blog_posts = BlogPost.objects.order_by('-pub_date')
    context = {
        'all_blog_posts': all_blog_posts,
    }
    return render(request, 'Blog/index.html', context)

def detail(request, post_id):
    post = get_object_or_404(BlogPost, pk=post_id)
    context = {
        'post': post
    }
    return render(request, 'Blog/detail.html', context)

def new(request):
    new_post_text = request.GET.get('post_text', '')
    if new_post_text == '':
        return render(request, 'Blog/new.html')
    else:
        new_blog_post = BlogPost(post_text=new_post_text, pub_date=timezone.now())
        new_blog_post.save()
        return HttpResponseRedirect(reverse('blog:detail', args=(new_blog_post.id,)))
