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