1from django.utils import timezone
2from django.views.generic.list import ListView
3
4from articles.models import Article
5
6class ArticleListView(ListView):
7
8 model = Article
9 paginate_by = 100 # if pagination is desired
10
11 def get_context_data(self, **kwargs):
12 context = super().get_context_data(**kwargs)
13 context['now'] = timezone.now()
14 return context
15
1from django.urls import path
2
3from article.views import ArticleDetailView
4
5urlpatterns = [
6 path('<slug:slug>/', ArticleDetailView.as_view(), name='article-detail'),
7]
8