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,9 +4,11 @@ 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):
class ForumView(View):
def get(self, request):
post_list = Post.objects.order_by("pub_date")
context = {
"post_list": post_list,
......
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