Show newsletters that are published

This commit is contained in:
Zak Timson 2017-09-15 10:48:42 -04:00
parent 243043eb5a
commit 65aa2c4ee8

View File

@ -1,12 +1,14 @@
import json
from django.db.models import Q
from django.shortcuts import render, HttpResponse
from django.utils import timezone
from .models import Newsletter, Subscriber
def newsletters(request):
newsletters = Newsletter.objects.filter(sent=True).order_by('-publish')
newsletters = Newsletter.objects.filter(Q(publish__lte=timezone.now())).order_by('-publish')
return render(request, 'newsletters.html', {'newsletters': newsletters})