Browse Source

djangoprojekt

master
parent
commit
7acbbe32c3
3 changed files with 13 additions and 3 deletions
  1. BIN
      news1/db.sqlite3
  2. 6
    0
      news1/posts/models.py
  3. 7
    3
      news1/posts/views.py

BIN
news1/db.sqlite3 View File


+ 6
- 0
news1/posts/models.py View File

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








+ 7
- 3
news1/posts/views.py 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)




Loading…
Cancel
Save