from django.shortcuts import render from django.http import HttpResponse from .models import Notice from django.utils import timezone import logging logger = None def init_loger(): global logger if logger == None: logger = logging.getLogger('django.db.backends') logger.setLevel(logging.DEBUG) logger.addHandler(logging.StreamHandler()) # Create your views here. def index(request): init_loger() notices = Notice.objects.all() notices = Notice.objects.filter(pub_start__lte=timezone.now(), pub_end__gte=timezone.now()) context = { "notices": notices, } return render(request, 'posts/index.html', context)