Commit 0a8a3ad8 authored by Lay Villanueva's avatar Lay Villanueva

Fixed views.py to display announcements in correct order

Changed Announcement.objects.all() to Announcement.objects.order_by('-pub_datetime') so the most recent announcement is at the top of the announcements board.
parent 946c0fd4
...@@ -8,7 +8,7 @@ from .models import Announcement, Reaction ...@@ -8,7 +8,7 @@ from .models import Announcement, Reaction
def index(request): def index(request):
output = "<h1><b> Widget's Announcement Board </b></h1> <br> <h3>Announcements:</h3>" output = "<h1><b> Widget's Announcement Board </b></h1> <br> <h3>Announcements:</h3>"
for announcement in Announcement.objects.all(): for announcement in Announcement.objects.order_by('-pub_datetime'):
output += '{} by {} {} published {}:<br> {} <br>'.format( output += '{} by {} {} published {}:<br> {} <br>'.format(
announcement.title, announcement.author.first_name, announcement.author.last_name, announcement.pub_datetime.strftime("%m/%d/%Y %I:%M %p"), announcement.body) announcement.title, announcement.author.first_name, announcement.author.last_name, announcement.pub_datetime.strftime("%m/%d/%Y %I:%M %p"), announcement.body)
......
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