bornhack-website/news/views.py

23 lines
576 B
Python
Raw Normal View History

2016-06-05 21:20:06 +00:00
from django.views.generic import ListView, DetailView
from django.utils import timezone
from .models import *
2016-05-30 19:36:14 +00:00
class NewsIndex(ListView):
model = NewsItem
2016-05-30 19:36:14 +00:00
template_name = 'news_index.html'
context_object_name = 'news_items'
2016-06-05 21:20:06 +00:00
def get_queryset(self):
return NewsItem.objects.filter(
published_at__isnull=False,
published_at__lt=timezone.now(),
archived=self.kwargs['archived']
)
2016-06-05 21:20:06 +00:00
class NewsDetail(DetailView):
model = NewsItem
2016-06-05 21:20:06 +00:00
template_name = 'news_detail.html'
context_object_name = 'news_item'
2016-06-05 21:20:06 +00:00