@login_required
def post_add(request):
    if (request.method == 'POST'):
        form = PostForm(request.POST)
        if form.is_valid():
            instance = form.save(commit=False)
            instance.user = request.user
            instance.save()
            messages.add_message(request, messages.SUCCESS, 'Blog Post Added')
            form = PostForm()
    else:
        form = PostForm()
    return render(request, 'blog/post_form.html', {'form': form})
@login_required
def post_add(request):
    if (request.method == 'POST'):
        form = PostForm(request.POST)
        if form.is_valid():
            instance = form.save(commit=False)
            instance.user = request.user
            instance.save()
            messages.add_message(request, messages.SUCCESS, 'Blog Post Added')
            form = PostForm()
    else:
        form = PostForm()
    return render(request, 'blog/post_form.html', {'form': form})