168fa3e8ec369ee27670adb2027a037eb55eee67
[styx.blog] / core / views.py
1 import datetime
2
3 from django.contrib.auth.models import User
4 from django.views.generic.detail import DetailView
5 from django.views.generic.list import ListView
6
7 from . import models
8
9 class PostDetailView(DetailView):
10     model = models.Post
11
12 class PostListView(ListView):
13     model = models.Post
14     paginate_by = 10
15
16     def get_queryset(self):
17         now = datetime.datetime.utcnow()
18
19         return super().get_queryset().filter(
20             publication_utc__lte=now,
21         ).order_by('-publication_utc')