21 lines
470 B
Python
21 lines
470 B
Python
from django.shortcuts import render
|
|
from django.views.generic import TemplateView
|
|
from .models import *
|
|
|
|
# Create your views here.
|
|
|
|
|
|
class HomeView(TemplateView):
|
|
template_name = 'home.html'
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
posts = list(Post.objects.all())
|
|
|
|
context['home'] = 'active'
|
|
context['highlight'] = posts[0]
|
|
context['posts'] = posts[1:]
|
|
|
|
return context
|