djangoprojekt

This commit is contained in:
Serge Beaujard Pouani Deumassi 2019-11-19 17:04:37 +01:00
parent e6b64e7877
commit 7acbbe32c3
3 changed files with 13 additions and 3 deletions

Binary file not shown.

View File

@ -5,3 +5,9 @@ class Notice(models.Model):
pub_start = models.DateTimeField()
pub_end = models.DateTimeField()

View File

@ -1,9 +1,13 @@
from django.shortcuts import render
from.models import Notice
from django.utils import timezone
# Create your views here.
def index(request):
return render(request, 'posts/index.html')
notices= Notice.objects.all()
notices= notices.filter(pub_start__lte=timezone.now())
notices= notices.filter(pub_end__gte= timezone.now())
context={"notices":notices}
return render(request, 'posts/notice.html', context)