Commit 992f3588 authored by Titia de Castro's avatar Titia de Castro

created and used template for announcements index

parent 54dbd67d
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Announcements</title>
</head>
<body>
<h1>Announcement Board</h1>
<h2>Important Announcements:</h2>
<ul>
{% for announcement in announcements %}
<li>{{ announcement.announcement_title }} by {{ announcement.author.first_name }} {{ announcement.author.last_name }} dated {{ announcement.pub_date|date:'d/m/Y' }}</li>
{% endfor %}
</ul>
</body>
</html>
\ No newline at end of file
......@@ -6,9 +6,4 @@ from .models import Announcement
# Create your views here.
def index(request):
formatted_announcements = "ANNOUNCEMENTS:<br>"
for announcement in Announcement.objects.all():
formatted_announcements += announcement.getAnnouncement() + "<br>"
return HttpResponse(formatted_announcements)
\ No newline at end of file
return render(request, 'index.html', {'announcements': Announcement.objects.order_by('-pub_date')})
\ 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