views.py 308 B

12345678
  1. from django.shortcuts import render
  2. from django.utils import timezone
  3. from .models import Post
  4. # Create your views here.
  5. def post_list(request):
  6. posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
  7. return render(request, 'blog/post_list.html', {'posts':posts})