Commit d62ea444 authored by Titia de Castro's avatar Titia de Castro

added announcement detail view

parent 992f3588
<!DOCTYPE html>
<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>Document</title>
</head>
<body>
<h1>{{ announcement.announcement_title }}</h1>
<h2>by {{ announcement.author.first_name }} {{ announcement.author.last_name }} dated {{ announcement.pub_date|date:'d/m/Y' }}</h2>
<p>
{{ announcement.announcement_body }}
</p>
{% for reaction in announcement.reactions.all %}
<p>{{ reaction.reaction_name }} Reactions: {{ reaction.getTally }}</p>
{% endfor %}
</body>
</html>
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic.detail import DetailView
from .models import Announcement from .models import Announcement
# Create your views here. # Create your views here.
def index(request): def index(request):
return render(request, 'index.html', {'announcements': Announcement.objects.order_by('-pub_date')}) return render(request, 'index.html', {'announcements': Announcement.objects.order_by('-pub_date')})
\ No newline at end of file
class AnnouncementDetailView(DetailView):
model = Announcement
\ 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