pages.views   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 9
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A IndexView.get_queryset() 0 3 1
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
19
# Without a class:
20
# def index(request):
21
#     return render(request, 'pages/index.html', context={})
22