Commit 7f851814 authored by Agu Syquia's avatar Agu Syquia

Updated views.py

Fixed views.py to work with the respective classes' templates
parent db406548
from django.http import HttpResponse
from django.shortcuts import render
from django.views.generic import CreateView, UpdateView, DetailView
from .models import Announcement, Reaction
# announcemnet view from .models
# announcemnet view for FBV implementation
def announcements_view(request):
announcements = Announcement.objects.all().order_by('-pub_datetime') #https://www.w3schools.com/django/django_queryset_orderby.php
return render(request, 'announcements.html', {'announcements': announcements})
# announcement detail view for CBV implementation
class AnnouncementsDetailsView(DetailView):
model = Announcement
template_name = 'announcement-details.html'
# add announcement, CBV implementation
class AnnouncementsAddView(CreateView):
model = Announcement
fields = '__all__'
template_name = 'announcement-add.html'
# edit announcement, CBV implementation
class AnnouncementsEditView(UpdateView):
model = Announcement
fields = '__all__'
template_name = 'announcement-edit.html'
def announcement_boardIndex(request):
announcements = Announcement.objects.all()
reactions = Reaction.objects.all()
......
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