from django.shortcuts import render, get_object_or_404
from django.utils import timezone
from .models import Post
from .forms import PostForm

# Create your views here.
def post_list(request):
    posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
    return render(request, 'blog/post_list.html', {'posts': posts})

def post_detail(request, pk):
    post = get_object_or_404(Post, pk=pk)
    return render(request, 'blog/post_detail.html', {'post': post})

def post_new(request, pk):
    post = get_object_or_404(Post, pk=pk)
    if request.method == "POST":
        form = PostForm(request.POST, instance=post)
        if form.is_valid():
            post = form.save(commit=False)
            post.author = request.user
            post.published_date = timezone.now()
            post.save()
            return redirect('blog.views.post_detail', pk=post.pk)
    else:
        form = PostForm(instance=post)
    return render(request, 'blog/post_edit.html', {'form': form})

@@ -503,32 +503,483 @@
 post_new(request
+):%0A    if request.method == %22POST%22:%0A        form = PostForm(request.POST)%0A        if form.is_valid():%0A            post = form.save(commit=False)%0A            post.author = request.user%0A            post.published_date = timezone.now()%0A            post.save()%0A            return redirect('blog.views.post_detail', pk=post.pk)%0A    else:%0A        form = PostForm()%0A    return render(request, 'blog/post_edit.html', %7B'form': form%7D)%0A    %0Adef post_edit(request
 , pk):%0A    post 

fix edit view