20 lines
664 B
Python
20 lines
664 B
Python
from django.shortcuts import render
|
|
from datetime import timedelta
|
|
from django.utils import timezone
|
|
from posts.models import Notice
|
|
# Create your views here.
|
|
|
|
|
|
#Titel und die Texte aller Meldungen, deren Veröffentlichungsdatum vor und der Endedatum nach dem aktuellen Datum liegt.
|
|
def home(request, value=""):
|
|
now = timezone.now()
|
|
notices = Notice.objects.all()
|
|
display_notices = list()
|
|
for notice in notices:
|
|
if notice.pub_start < now and notice.pub_end > now:
|
|
display_notices.append(notice)
|
|
context = {
|
|
"title": "Beboop",
|
|
"notices": display_notices
|
|
}
|
|
return render(request, 'index.html', context) |