webeng/news/posts/views.py

15 lines
455 B
Python
Raw Normal View History

from django.shortcuts import render
from django.http import HttpResponse
2019-11-19 12:48:20 +01:00
from .models import Notice
from django.utils import timezone
# Create your views here.
def index(request):
2019-11-19 12:48:20 +01:00
notices = Notice.objects.all()
notices = Notice.objects.filter(pub_start__lte=timezone.now())
notices = Notice.objects.filter(pub_end__gte=timezone.now())
context = {
"notices": notices,
}
return render(request, 'posts/index.html', context)