Commit 0d12a9a3 authored by Ryan Angelo G. Lim's avatar Ryan Angelo G. Lim

Changed a FBV into a CBV

parent 1e5668a8
from django.urls import path
from django.conf.urls.static import static
from . import views
from .views import ForumView
app_name="forum"
urlpatterns = [
path('', views.index, name="forum"),
path('', ForumView.as_view(), name="forum"),
path('posts/add/', views.add, name="add"),
path('posts/<int:post_id>/details/', views.details, name="details"),
]
......@@ -4,14 +4,16 @@ from forum.models import Post, Reply, WidgetUser
from django.shortcuts import render, redirect
from django.template import loader
from .forms import PostForm
from django.views import View
# Create your views here.
def index(request):
post_list = Post.objects.order_by("pub_date")
context = {
"post_list": post_list,
}
return render(request, "forum/index.html", context)
class ForumView(View):
def get(self, request):
post_list = Post.objects.order_by("pub_date")
context = {
"post_list": post_list,
}
return render(request, "forum/index.html", context)
def getReply(pk):
postReply = []
......
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