Lösungen der Aufgaben vom Kurs MEIM1 - Web Engineering von Prof. Hofmann
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 673B

123456789101112131415161718192021222324
  1. from django.shortcuts import render
  2. from django.http import HttpResponse
  3. from .models import Notice
  4. from django.utils import timezone
  5. import logging
  6. logger = None
  7. def init_loger():
  8. global logger
  9. if logger == None:
  10. logger = logging.getLogger('django.db.backends')
  11. logger.setLevel(logging.DEBUG)
  12. logger.addHandler(logging.StreamHandler())
  13. # Create your views here.
  14. def index(request):
  15. init_loger()
  16. notices = Notice.objects.all()
  17. notices = Notice.objects.filter(pub_start__lte=timezone.now(), pub_end__gte=timezone.now())
  18. context = {
  19. "notices": notices,
  20. }
  21. return render(request, 'posts/index.html', context)