from django.shortcuts import render
from django.http import HttpResponse
from .models import Blogpost
# Create your views here.


def index(request):

    blogpost = Blogpost.objects.all()
    rev_blog = Blogpost.objects.order_by('-post_id')
    params = {'rev_blog': rev_blog, 'blogpost': blogpost}
    return render(request, 'blog/index.html', params)


def blogpost(request, id):
    post = Blogpost.objects.filter(post_id=id)[0]
    return render(request, 'blog/blogpost.html', {'post': post})
