djangoprojekt
This commit is contained in:
parent
e6b64e7877
commit
7acbbe32c3
BIN
news1/db.sqlite3
BIN
news1/db.sqlite3
Binary file not shown.
@ -5,3 +5,9 @@ class Notice(models.Model):
|
||||
pub_start = models.DateTimeField()
|
||||
pub_end = models.DateTimeField()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user