Commit 9adb11a1 authored by Cherish Magpayo's avatar Cherish Magpayo

Add announcements detail view and modify announcements index to use html template

parent f81a0da8
from django.http import HttpResponse
from django.http import HttpResponse, Http404
from django.shortcuts import render
from announcements.models import Announcement
# Create your views here.
def index(request):
announcement_list = Announcement.objects.order_by("pub_date")
context = {
"announcement_list": announcement_list,
}
return render(request, "announcements/index.html", context)
def details(request, announcement_id):
try:
announcement = Announcement.objects.get(pk=announcement_id)
except Announcement.DoesNotExist:
raise Http404("Announcement does not exist!")
return render(request, "announcements/details.html", {"announcement": announcement})
""" midterms
announcement_objects = Announcement.objects.all()
response = "ANNOUNCEMENTS:<br>"
......@@ -17,4 +36,5 @@ def index(request):
+ f"dated {announcement.pub_date.date()}:<br> {announcement.announcement_body} <br>"
+ f"Like: {like} <br> Love: {love} <br> Angry: {angry}<br><br>")
return HttpResponse(response)
\ No newline at end of file
return HttpResponse(response)
"""
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment