You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

views.py 391B

123456789101112
  1. from django.shortcuts import render
  2. from .models import Notice
  3. from django.utils import timezone
  4. # Create your views here.
  5. def index(request):
  6. notices = Notice.objects.all()
  7. notices = notices.filter(pub_start__lte=timezone.now() )
  8. notices = notices.filter(pub_end__gte=timezone.now() )
  9. context = { "notices": notices}
  10. return render(request, 'Posts/index.html', context)