from django.shortcuts import render, get_object_or_404, Http404
from django.views import generic
from .models import Post

class PostListView(generic.ListView):
    model = Post
    context_object_name = 'post_list'
    queryset = Post.objects.filter()[:4]
    template_name = 'home/homepage.html'

class PostDetailView(generic.DetailView):
    model = Post
    template_name = 'home/postdetail.html'
    def post_detail_view(request, pk):
        try:
            post_id = Post.objects.get(pk = pk)
        except Post.DoesNotExist:
            raise Http404("ops")

        return render(request, context={'post': post_id,})




#def home(request):
#    return render(request, 'home/homepage.html')

fc2c1904b95997f99a69c69d42a04c478d5c7d33
<mask token>


class PostDetailView(generic.DetailView):
    <mask token>
    <mask token>

    def post_detail_view(request, pk):
        try:
            post_id = Post.objects.get(pk=pk)
        except Post.DoesNotExist:
            raise Http404('ops')
        return render(request, context={'post': post_id})

<mask token>


class PostListView(generic.ListView):
    <mask token>
    <mask token>
    <mask token>
    <mask token>


class PostDetailView(generic.DetailView):
    model = Post
    template_name = 'home/postdetail.html'

    def post_detail_view(request, pk):
        try:
            post_id = Post.objects.get(pk=pk)
        except Post.DoesNotExist:
            raise Http404('ops')
        return render(request, context={'post': post_id})

<mask token>


class PostListView(generic.ListView):
    model = Post
    context_object_name = 'post_list'
    queryset = Post.objects.filter()[:4]
    template_name = 'home/homepage.html'


class PostDetailView(generic.DetailView):
    model = Post
    template_name = 'home/postdetail.html'

    def post_detail_view(request, pk):
        try:
            post_id = Post.objects.get(pk=pk)
        except Post.DoesNotExist:
            raise Http404('ops')
        return render(request, context={'post': post_id})

from django.shortcuts import render, get_object_or_404, Http404
from django.views import generic
from .models import Post


class PostListView(generic.ListView):
    model = Post
    context_object_name = 'post_list'
    queryset = Post.objects.filter()[:4]
    template_name = 'home/homepage.html'


class PostDetailView(generic.DetailView):
    model = Post
    template_name = 'home/postdetail.html'

    def post_detail_view(request, pk):
        try:
            post_id = Post.objects.get(pk=pk)
        except Post.DoesNotExist:
            raise Http404('ops')
        return render(request, context={'post': post_id})

from django.shortcuts import render, get_object_or_404, Http404
from django.views import generic
from .models import Post

class PostListView(generic.ListView):
    model = Post
    context_object_name = 'post_list'
    queryset = Post.objects.filter()[:4]
    template_name = 'home/homepage.html'

class PostDetailView(generic.DetailView):
    model = Post
    template_name = 'home/postdetail.html'
    def post_detail_view(request, pk):
        try:
            post_id = Post.objects.get(pk = pk)
        except Post.DoesNotExist:
            raise Http404("ops")

        return render(request, context={'post': post_id,})




#def home(request):
#    return render(request, 'home/homepage.html')
