Total Complexity | 1 |
Total Lines | 18 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """ This file contains the views, the 'pages' of the website. """ |
||
2 | from django.utils import timezone |
||
3 | from django.views import generic |
||
4 | |||
5 | from .models import Article |
||
6 | |||
7 | |||
8 | # class IndexView(generic.TemplateView): |
||
9 | class IndexView(generic.ListView): |
||
10 | """" Index of all pages, i.e. home page. """ |
||
11 | template_name = 'pages/index.html' |
||
12 | # Provide name of the context variable returned by get_queryset? |
||
13 | context_object_name = 'article_list' |
||
14 | |||
15 | def get_queryset(self) -> None: |
||
16 | """" Find the home article and display it. """ |
||
17 | return Article.objects.filter(published_date__lt=timezone.now()).order_by('published_date') |
||
18 | |||
22 |