Commit df549949 authored by Junho Park's avatar Junho Park

chore: changed announcements index FBV to CBV

parent ea93bc35
from django.urls import path from django.urls import path
from . import views from . import views
from .views import AnnouncementsPageView
urlpatterns = [ urlpatterns = [
path("", views.index, name='Announcements'), path("", AnnouncementsPageView.as_view(), name='Announcements'),
path("<int:announcement_id>/details/", views.details, name="details"), path("<int:announcement_id>/details/", views.details, name="details"),
path("add/", views.add, name='add'), path("add/", views.add, name='add'),
......
...@@ -2,16 +2,19 @@ from django.http import HttpResponse, Http404 ...@@ -2,16 +2,19 @@ from django.http import HttpResponse, Http404
from .models import Announcement, Reaction from .models import Announcement, Reaction
from django.shortcuts import render,redirect from django.shortcuts import render,redirect
from .forms import AnnouncementForm from .forms import AnnouncementForm
from django.views import View
# Create your views here. # Create your views here.
# announcements/ # announcements/
def index(request): class AnnouncementsPageView(View):
announcement_list = Announcement.objects.order_by("pub_date") def get(self, request):
context = { announcement_list = Announcement.objects.order_by("pub_date")
"announcement_list": announcement_list, context = {
} "announcement_list": announcement_list,
return render(request, "announcements/index.html", context) }
return render(request, "announcements/index.html", context)
# announcements/<announncements_id>/details # announcements/<announncements_id>/details
def details(request, announcement_id): def details(request, announcement_id):
......
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