bornhack-website/news/views.py
2017-01-20 16:18:10 +01:00

23 lines
576 B
Python

from django.views.generic import ListView, DetailView
from django.utils import timezone
from .models import *
class NewsIndex(ListView):
model = NewsItem
template_name = 'news_index.html'
context_object_name = 'news_items'
def get_queryset(self):
return NewsItem.objects.filter(
published_at__isnull=False,
published_at__lt=timezone.now(),
archived=self.kwargs['archived']
)
class NewsDetail(DetailView):
model = NewsItem
template_name = 'news_detail.html'
context_object_name = 'news_item'