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