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,15 +2,18 @@ from django.http import HttpResponse, Http404 ...@@ -2,15 +2,18 @@ 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):
def get(self, request):
announcement_list = Announcement.objects.order_by("pub_date") announcement_list = Announcement.objects.order_by("pub_date")
context = { context = {
"announcement_list": announcement_list, "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
......
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