Commit 3c614762 authored by Alia Lawraine Olay's avatar Alia Lawraine Olay

Edited views.py to display Announcement entries

parent 1eafa94e
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from .models import Announcement
def index(request): def index(request):
return HttpResponse("This is the Announcement Board!") heading = 'ANNOUNCEMENTS:<br>'
all_announcements = Announcement.objects.all()
body = ''
for announcement in all_announcements:
count_like = announcement.reactions.filter(reaction_name='Like').count()
count_love = announcement.reactions.filter(reaction_name='Love').count()
count_angry = announcement.reactions.filter(reaction_name='Angry').count()
body += '{} by {} {} dated {}:<br>{}<br>Like: {}<br>Love: {}<br>Angry: {}<br><br>'.format(
announcement.announcement_title, announcement.author.first_name,
announcement.author.last_name, announcement.pub_date,
announcement.announcement_body, count_like,
count_love, count_angry
)
return HttpResponse(heading + body)
\ 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